centreon / centreon-plugins

Collection of standard plugins to discover and gather cloud-to-edge metrics and status across your whole IT infrastructure.
https://www.centreon.com
Apache License 2.0
310 stars 274 forks source link

os::linux::local::plugin --mode check-plugin #4409

Open jbeaujour opened 1 year ago

jbeaujour commented 1 year ago

Question

Hello We want to use the "os::linux::local::plugin" plugin with "check-plugin" mode in a bash script that receives command line arguments. Here is an example of the script and arguments: ./check_script --url 'https://host/url/' --search 'pattern' -t 50 -p '{}' --proxy none --state 0 --agent 'none'

When I launch the centreon plugin directly it works fine: /usr/lib/centreon/plugins/centreon_plugins.pl --plugin os::linux::local::plugin --mode check-plugin --hostname hostname --ssh-username username --command='/opt/plugins /check_script --url 'https://host/url/' --search 'pattern' -t 50 -p '{}' --proxy none --state 0 --agent 'none'' OK - Accessible URL 'https://host/url/' (200) | 'time'=2.34s;0;60;; 'maintenance'=0;0;1;; 'sla'=1;0;1;; 'command1#ssh.response.time.seconds'=43.445s;;;0;

on the other hand, if I include it in the check_script by rebuilding the centreon parameters of "--command" with the arguments passed to the script, I get an error message: "Unknown option: url at /usr/lib/centreon/plugins/centreon/plugins/alternative/Getopt.pm line 67."

my request for help: how to retrieve the arguments from the bash script and pass them to the centreon plugin Thanks for your help

garnier-quentin commented 1 year ago

Have you tried to execute it with double-quotes ?

--command="/opt/plugins/check_script --url 'https://host/url/' --search 'pattern' -t 50 -p '{}' --proxy none --state 0 --agent 'none' "
lucie-dubrunfaut commented 2 months ago

Hello :)

Without additional information we are not able to provide a solution or resolve a possible bug. So @jbeaujour if you still need a response / solution to this issue, can you try Quentin's solution? Otherwise we will be forced to close this issue.