Module: monitoring-plugins
 Branch: master
 Commit: fafaee5813830c5ad963f4855566be9a4a6dfc22
 Author: Lorenz Kästle <[email protected]>
   Date: Sat Oct 18 12:25:44 2025 +0200
    URL: 
https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=fafaee58

Fix some bugs after refactoring

---

 plugins/check_dbi.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/plugins/check_dbi.c b/plugins/check_dbi.c
index 2e110ce3..786fc1b6 100644
--- a/plugins/check_dbi.c
+++ b/plugins/check_dbi.c
@@ -29,6 +29,7 @@
  *
  *****************************************************************************/
 
+#include "states.h"
 const char *progname = "check_dbi";
 const char *copyright = "2011-2024";
 const char *email = "[email protected]";
@@ -101,13 +102,15 @@ int main(int argc, char **argv) {
                printf("Initializing DBI\n");
        }
 
-       dbi_inst *instance_p = NULL;
-       if (dbi_initialize_r(NULL, instance_p) < 0) {
+       dbi_inst instance_p = NULL;
+       if (dbi_initialize_r(NULL, &instance_p) < 0) {
                printf(
                        "UNKNOWN - failed to initialize DBI; possibly you don't 
have any drivers installed.\n");
                return STATE_UNKNOWN;
        }
 
+       dbi_set_verbosity_r(0, instance_p);
+
        if (instance_p == NULL) {
                printf("UNKNOWN - failed to initialize DBI.\n");
                return STATE_UNKNOWN;
@@ -230,7 +233,6 @@ int main(int argc, char **argv) {
                }
        }
 
-
        const char *query_val_str = NULL;
        double query_val = 0.0;
        double query_time = 0.0;
@@ -251,10 +253,15 @@ int main(int argc, char **argv) {
                                        status = STATE_OK;
                                }
                        } else if (config.expect_re_str) {
-                               int err;
-
+                               int comp_err;
                                regex_t expect_re = {};
-                               err = regexec(&expect_re, query_val_str, 0, 
NULL, /* flags = */ 0);
+                               comp_err = regcomp(&expect_re, 
config.expect_re_str, config.expect_re_cflags);
+                               if (comp_err != 0) {
+                                       // TODO error, failed to compile regex
+                                       return STATE_UNKNOWN;
+                               }
+
+                               int err = regexec(&expect_re, query_val_str, 0, 
NULL, /* flags = */ 0);
                                if (!err) {
                                        status = STATE_OK;
                                } else if (err == REG_NOMATCH) {

Reply via email to