Skip to main content

Hello,

I have the following command :

/usr/lib/centreon/plugins//centreon_linux_ssh.pl --plugin=os::linux::local::plugin --mode=cmd-return --hostname='1.2.3.4' --ssh-backend='libssh' --ssh-username='my_user' --ssh-password='' --ssh-port=''  --exec-command='/home/my_user/my_script.sh'  --exec-command-options='' --manage-returns='%(code) == 0,OK,All is fine#%(code) == 1,WARNING,Little problem#%(code) == 2,CRITICAL,Big problem#,UNKNOWN,Command problem' --verbose

I have no problem with this command, but I’m not fully satisfied

My script (my_script.sh) returns one line of text in all cases, and I want to get this output in --manage-return option

How can I do this?

Many thanks for your help!

hello

from the plugin source I could understand, the only “variable” you can use is %(code), the stdout from the command is parsed, and if matched it will trigger whichever case it needs, but the stdout of the command is not displayed.

I think is intended but that “cmdreturn” check is specifically design to work only with the Return Code. (and prevent issues with outputs error, multiline, huge text, security issue?, no idea what was the decision behind this choice)

 

there is an “ideas” for suggestion at the top of this page, you could ask for a updated check or an evolution.

 

alternatively there was an old “check_by_ssh” in previous version of centreon, from old nagios exchange, this would have done what you want, it would use the libssh, run with a user (with pre-approved key exchanged from centreon-engine to the host) and return the code and full stdout text.

but this is a command you would need to compile yourself, as it is not provided by centreon


Reply