shinken-monitoring / mod-ws-arbiter

Shinken module for listening external commands from a web service
GNU Affero General Public License v3.0
3 stars 9 forks source link

Cannot execute commands reload / restart #11

Open fguay opened 9 years ago

fguay commented 9 years ago

Hello,

I use shinken 2.2 with ws-arbiter in receiver daemon. When I try to use WS-Arbiter with reload ws

curl -d '' http://172.23.114.12:7760/reload

I have that in the log :

==> /var/log/shinken/receiverd.log <==
[1424160740] WARNING: [receiver-master] [WS_Arbiter] command: [1424160740] RELOAD_CONFIG

==> /var/log/shinken/arbiterd.log <==
[1424160740] DEBUG: [Shinken] Posting to http://localhost:7772/push_broks: 14B
[1424160740] EXTERNAL COMMAND: [1424160740] RELOAD_CONFIG
[1424160740] DEBUG: [Shinken] mode= dispatcher, global= True
[1424160740] DEBUG: [Shinken] Got commands RELOAD_CONFIG []
[1424160740] WARNING: [Shinken] RELOAD command : sudo /etc/init.d/shinken reload
[1424160740] ERROR: [Shinken] Cannot reload Shinken configuration: the 'reload-shinken' command failed with the error code '1' and the text ''.

I have strictly the same with restart ws.

==> /var/log/shinken/receiverd.log <==
[1424161029] WARNING: [receiver-master] [WS_Arbiter] command: [1424161029] RESTART_PROGRAM

==> /var/log/shinken/arbiterd.log <==
[1424161029] DEBUG: [Shinken] Posting to http://localhost:7772/push_broks: 14B
[1424161030] DEBUG: [Shinken] Posting to http://localhost:7772/push_broks: 14B
[1424161030] EXTERNAL COMMAND: [1424161029] RESTART_PROGRAM
[1424161030] DEBUG: [Shinken] mode= dispatcher, global= True
[1424161030] DEBUG: [Shinken] Got commands RESTART_PROGRAM []
[1424161030] WARNING: [Shinken] RESTART command : sudo /etc/init.d/shinken restart
[1424161030] ERROR: [Shinken] Cannot restart Shinken : the 'restart-shinken' command failed with the error code '1' and the text ''.

I try the target command directly with my user shinken and it's work fine :

[root@hapi-fgu-shinken-1 shinken]# su - shinken
Dernière connexion : lundi 16 février 2015 à 17:45:08 CET sur pts/0
-bash-4.2$ sudo /etc/init.d/shinken reload
Reloading arbiter
Doing config check                                                 [  OK  ]

I put the daemon in debug mode but I didn't have more information.

I checked the issue #8 but my command reload/restart are correctly in directory /etc/shinken/commands and seems to be correct.

-bash-4.2$ ll /etc/shinken/commands/
total 84
....
-rw-r--r--. 1 shinken shinken 115 Feb 16 18:13 reload-shinken.cfg
-rw-r--r--. 1 shinken shinken 117 Feb 16 16:22 restart-shinken.cfg
-bash-4.2$ more /etc/shinken/commands/*-shinken.cfg 
::::::::::::::
/etc/shinken/commands/reload-shinken.cfg
::::::::::::::
define command {
    command_name        reload-shinken
    command_line        sudo /etc/init.d/shinken reload
}

::::::::::::::
/etc/shinken/commands/restart-shinken.cfg
::::::::::::::
define command {
    command_name        restart-shinken
    command_line        sudo /etc/init.d/shinken restart
}

Last idea, I checked selinux audit log and there are nothing about this command and my shinken user is sudoers.

Thanks for your help.

Seb-Solon commented 9 years ago

It reminds me this : naparuba/shinken#1488

Can you try without sudo and edit the sudoers properly?

fguay commented 9 years ago

Hi Seb,

So, I changed the command file reload-shinken like this :

[root@hapi-fgu-shinken-1 centos]# more /etc/shinken/commands/reload-shinken.cfg 
define command {
    command_name        reload-shinken
    command_line           /etc/init.d/shinken reload
}

And it work fine. I didn't really understood why, but it works.

Thanks for your help and your job on this mod.

fguay commented 9 years ago

Idem for /etc/shinken/commands/restart-shinken.cfg. It works fine without sudo.