Skip to main content
Solved

Plugin Linux-SSH, cmd-return : get output of a bash script

  • September 19, 2024
  • 2 replies
  • 225 views

Forum|alt.badge.img

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!

Best answer by christophe.niel-ACT

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

2 replies

Forum|alt.badge.img+17
  • Centreon Lord Commander
  • 408 replies
  • Answer
  • September 19, 2024

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


Forum|alt.badge.img+5
  • Steward **
  • 68 replies
  • September 5, 2025

Hello Steward,

I have a problem identical to yours. How did you actually solve it?

Sincerely,

Eric