Solved

centreon does not launch a bash .sh script

  • 30 March 2022
  • 5 replies
  • 663 views

Badge +1

Hello,

I created a simple bash script and a verification command :

/usr/lib/centreon/plugins/test2.sh

 

For the test i tried :

chmod 777 test2.sh

chown centreon:root test2.sh

 

Manuelly the script works with centreon user but he doesn’t when i try by centeon gui.

 

icon

Best answer by akhethan 30 March 2022, 16:19

View original

5 replies

Userlevel 3
Badge +9

Hello @akhethan,

 

It is the ‘centreon-engine’ user that execute your commands. What is the error command on the Web interface ?

 

Regards.

Badge +1

i tried too : chown centreon-engine:root test2.sh

 

this is my command

 

the error command in on web interface is :

(No output returned from plugin)

 

this is normal because it is a test script which does not return anything, normally if the script is executed there should be a file created. here is my test script :

 

#!/bin/bash
NOW=$(date +"%m-%d-%Y")
RAND=$[ 1 + $[ RANDOM % 100000 ]]
echo test  >> "temp.$NOW.$RAND"

Userlevel 3
Badge +9

What happen when you exectute the following command ?

su - centreon-engine -s /bin/bash -c <Path of your script>

 

Badge +1

if I run the command:

su - centreon-engine -s /bin/bash -c /usr/lib/centreon/plugins/test2.sh

the script is launched and the word test is displayed on the screen, however this does not create the file and that is what interests me.

 

here are the rights to the plugins directory :

 

 

moreover I have just tested the same command with the root user and I have the same result, on the other hand if I place myself in the directory and that I execute the script in root it works

 

Badge +1

Solved !

I found my mistake and it's not centreon's fault but me, in my script I ask to create a file and you had to put the full path

I wanted to thank you because it is thanks to your help that I found.

Reply