summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/output.c17
-rw-r--r--plugins/check_curl.c37
2 files changed, 42 insertions, 12 deletions
diff --git a/lib/output.c b/lib/output.c
index d1a8d3b9..bfd43195 100644
--- a/lib/output.c
+++ b/lib/output.c
@@ -259,6 +259,21 @@ mp_state_enum mp_eval_check_default(const mp_check check) {
259 return result; 259 return result;
260} 260}
261 261
262// Remove troublesome symbols from plugin output
263char *sanitize_output_insitu(char *input) {
264 if (input == NULL) {
265 return input;
266 }
267
268 for (char *walker = input; *walker != '\0'; walker++) {
269 if (*walker == '|') {
270 *walker = ' ';
271 }
272 }
273
274 return input;
275}
276
262/* 277/*
263 * Generate output string for a mp_check object 278 * Generate output string for a mp_check object
264 * Non static to be available for testing functions 279 * Non static to be available for testing functions
@@ -299,6 +314,8 @@ char *mp_fmt_output(mp_check check) {
299 subchecks = subchecks->next; 314 subchecks = subchecks->next;
300 } 315 }
301 316
317 result = sanitize_output_insitu(result);
318
302 if (pd_string != NULL && strlen(pd_string) > 0) { 319 if (pd_string != NULL && strlen(pd_string) > 0) {
303 asprintf(&result, "%s|%s", result, pd_string); 320 asprintf(&result, "%s|%s", result, pd_string);
304 } 321 }
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index 4a1fb647..f63cdea2 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -239,10 +239,35 @@ mp_subcheck check_http(const check_curl_config config, check_curl_working_state
239 // ============== 239 // ==============
240 CURLcode res = curl_easy_perform(curl_state.curl); 240 CURLcode res = curl_easy_perform(curl_state.curl);
241 241
242 if (verbose > 1) {
243 printf("* curl_easy_perform returned: %s\n", curl_easy_strerror(res));
244 }
245
242 if (verbose >= 2 && workingState.http_post_data) { 246 if (verbose >= 2 && workingState.http_post_data) {
243 printf("**** REQUEST CONTENT ****\n%s\n", workingState.http_post_data); 247 printf("**** REQUEST CONTENT ****\n%s\n", workingState.http_post_data);
244 } 248 }
245 249
250 // curl_state is updated after curl_easy_perform, and with updated curl_state certificate checks can be done
251 // Check_http tries to check certs as early as possible, and exits with certificate check result by default. Behave similarly.
252#ifdef LIBCURL_FEATURE_SSL
253 if (workingState.use_ssl && config.check_cert) {
254 if (verbose > 1) {
255 printf("* adding a subcheck for the certificate\n");
256 }
257 mp_subcheck sc_certificate = check_curl_certificate_checks(
258 curl_state.curl, cert, config.days_till_exp_warn, config.days_till_exp_crit);
259
260 mp_add_subcheck_to_subcheck(&sc_result, sc_certificate);
261 if (!config.continue_after_check_cert) {
262 if (verbose > 1) {
263 printf("* returning after adding the subcheck for certificate, continuing after "
264 "checking the certificate is turned off\n");
265 }
266 return sc_result;
267 }
268 }
269#endif
270
246 mp_subcheck sc_curl = mp_subcheck_init(); 271 mp_subcheck sc_curl = mp_subcheck_init();
247 272
248 /* Curl errors, result in critical Nagios state */ 273 /* Curl errors, result in critical Nagios state */
@@ -283,18 +308,6 @@ mp_subcheck check_http(const check_curl_config config, check_curl_working_state
283 // Evaluation 308 // Evaluation
284 // ========== 309 // ==========
285 310
286#ifdef LIBCURL_FEATURE_SSL
287 if (workingState.use_ssl && config.check_cert) {
288 mp_subcheck sc_certificate = check_curl_certificate_checks(
289 curl_state.curl, cert, config.days_till_exp_warn, config.days_till_exp_crit);
290
291 mp_add_subcheck_to_subcheck(&sc_result, sc_certificate);
292 if (!config.continue_after_check_cert) {
293 return sc_result;
294 }
295 }
296#endif
297
298 /* we got the data and we executed the request in a given time, so we can append 311 /* we got the data and we executed the request in a given time, so we can append
299 * performance data to the answer always 312 * performance data to the answer always
300 */ 313 */