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 273 forks source link

Mosquitto plugin string-value Regex not works #5081

Open mdepedrof opened 2 months ago

mdepedrof commented 2 months ago

Quick description

It seems that the plugin "centreon_eclipse_mosquitto_mqtt.pl" does not work correctly when evaluating critical/warning regular expressions.

Bug report

I have a MQTT broker configured and a topic with state that can be true or false image

I am running the script with these options:

/usr/lib/centreon/plugins//centreon_eclipse_mosquitto_mqtt.pl \
--plugin=apps::eclipse::mosquitto::mqtt::plugin \
--mode=string-value \
--hostname='x.x.x.x' \
--mqtt-port='1883' \
--mqtt-ca-certificate='' \
--mqtt-ssl-certificate='' \
--mqtt-ssl-key='' \
--mqtt-username='user' \
--mqtt-password='pass' \
--mqtt-ssl='0' \
--mqtt-allow-insecure \
--topic='nuki/xxxxx/connected' \
--format-custom='' \
--warning-regexp='' \
--critical-regexp='^(?!(true)).*' \
--unknown-regexp='' \
--format-ok='value: %{value}' \
--format-warning='value: %{value}' \
--format-critical='value: %{value}' \
--format-unknown='value: %{value}' \
--debug

I always get the same result OK: value: false

How to reproduce

Expected result

I Think the expected result would be ´´´Critical: value: false``` and the check must be critical state

Actual result

I always recieve OK: value: false and the check always show the OK status

Additional info

I try with diferent regex as:

Also, with the last RegExp, I have tested with an online validator and the result is correct. Match when the value is different from "true" so when you get "false" it should detect it as CRITICAL. image

However, I always get the same result: OK: value: false

lucie-dubrunfaut commented 1 month ago

Hello :)

Thank you for this feedback, we will inspect the problem and get back to you when we know more about it.