summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_dbi.c19
1 files 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 @@
29 * 29 *
30 *****************************************************************************/ 30 *****************************************************************************/
31 31
32#include "states.h"
32const char *progname = "check_dbi"; 33const char *progname = "check_dbi";
33const char *copyright = "2011-2024"; 34const char *copyright = "2011-2024";
34const char *email = "devel@monitoring-plugins.org"; 35const char *email = "devel@monitoring-plugins.org";
@@ -101,13 +102,15 @@ int main(int argc, char **argv) {
101 printf("Initializing DBI\n"); 102 printf("Initializing DBI\n");
102 } 103 }
103 104
104 dbi_inst *instance_p = NULL; 105 dbi_inst instance_p = NULL;
105 if (dbi_initialize_r(NULL, instance_p) < 0) { 106 if (dbi_initialize_r(NULL, &instance_p) < 0) {
106 printf( 107 printf(
107 "UNKNOWN - failed to initialize DBI; possibly you don't have any drivers installed.\n"); 108 "UNKNOWN - failed to initialize DBI; possibly you don't have any drivers installed.\n");
108 return STATE_UNKNOWN; 109 return STATE_UNKNOWN;
109 } 110 }
110 111
112 dbi_set_verbosity_r(0, instance_p);
113
111 if (instance_p == NULL) { 114 if (instance_p == NULL) {
112 printf("UNKNOWN - failed to initialize DBI.\n"); 115 printf("UNKNOWN - failed to initialize DBI.\n");
113 return STATE_UNKNOWN; 116 return STATE_UNKNOWN;
@@ -230,7 +233,6 @@ int main(int argc, char **argv) {
230 } 233 }
231 } 234 }
232 235
233
234 const char *query_val_str = NULL; 236 const char *query_val_str = NULL;
235 double query_val = 0.0; 237 double query_val = 0.0;
236 double query_time = 0.0; 238 double query_time = 0.0;
@@ -251,10 +253,15 @@ int main(int argc, char **argv) {
251 status = STATE_OK; 253 status = STATE_OK;
252 } 254 }
253 } else if (config.expect_re_str) { 255 } else if (config.expect_re_str) {
254 int err; 256 int comp_err;
255
256 regex_t expect_re = {}; 257 regex_t expect_re = {};
257 err = regexec(&expect_re, query_val_str, 0, NULL, /* flags = */ 0); 258 comp_err = regcomp(&expect_re, config.expect_re_str, config.expect_re_cflags);
259 if (comp_err != 0) {
260 // TODO error, failed to compile regex
261 return STATE_UNKNOWN;
262 }
263
264 int err = regexec(&expect_re, query_val_str, 0, NULL, /* flags = */ 0);
258 if (!err) { 265 if (!err) {
259 status = STATE_OK; 266 status = STATE_OK;
260 } else if (err == REG_NOMATCH) { 267 } else if (err == REG_NOMATCH) {