summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-12-17 17:19:21 +0100
committerGitHub <noreply@github.com>2025-12-17 17:19:21 +0100
commit828a9720b10814c5836d03aa35af05d196c4104b (patch)
tree47414aa6a2846650448a77ce836219d65c97eb57 /plugins
parent68fc05381ee5fa0aee1413118fbb3d81ca888b09 (diff)
parent6ce11bc44f5fe2344083a94175a1667ca02e016c (diff)
downloadmonitoring-plugins-828a9720b10814c5836d03aa35af05d196c4104b.tar.gz
Merge pull request #2202 from oxzi/fringe-unix-build-fixes-for-v3.0.0-rc1HEADmaster
Fix v3.0.0-rc1 Build on OpenBSD
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_by_ssh.c34
-rw-r--r--plugins/check_smtp.c1
2 files changed, 17 insertions, 18 deletions
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c
index df8907d9..7ffa0ded 100644
--- a/plugins/check_by_ssh.c
+++ b/plugins/check_by_ssh.c
@@ -98,7 +98,7 @@ int main(int argc, char **argv) {
98 if (child_result.cmd_error_code == 255 && config.unknown_timeout) { 98 if (child_result.cmd_error_code == 255 && config.unknown_timeout) {
99 mp_subcheck sc_ssh_execution = mp_subcheck_init(); 99 mp_subcheck sc_ssh_execution = mp_subcheck_init();
100 xasprintf(&sc_ssh_execution.output, "SSH connection failed: %s", 100 xasprintf(&sc_ssh_execution.output, "SSH connection failed: %s",
101 child_result.stderr.lines > 0 ? child_result.stderr.line[0] 101 child_result.err.lines > 0 ? child_result.err.line[0]
102 : "(no error output)"); 102 : "(no error output)");
103 103
104 sc_ssh_execution = mp_set_subcheck_state(sc_ssh_execution, STATE_UNKNOWN); 104 sc_ssh_execution = mp_set_subcheck_state(sc_ssh_execution, STATE_UNKNOWN);
@@ -107,34 +107,34 @@ int main(int argc, char **argv) {
107 } 107 }
108 108
109 if (verbose) { 109 if (verbose) {
110 for (size_t i = 0; i < child_result.stdout.lines; i++) { 110 for (size_t i = 0; i < child_result.out.lines; i++) {
111 printf("stdout: %s\n", child_result.stdout.line[i]); 111 printf("stdout: %s\n", child_result.out.line[i]);
112 } 112 }
113 for (size_t i = 0; i < child_result.stderr.lines; i++) { 113 for (size_t i = 0; i < child_result.err.lines; i++) {
114 printf("stderr: %s\n", child_result.stderr.line[i]); 114 printf("stderr: %s\n", child_result.err.line[i]);
115 } 115 }
116 } 116 }
117 117
118 size_t skip_stdout = 0; 118 size_t skip_stdout = 0;
119 if (config.skip_stdout) { /* --skip-stdout specified without argument */ 119 if (config.skip_stdout) { /* --skip-stdout specified without argument */
120 skip_stdout = child_result.stdout.lines; 120 skip_stdout = child_result.out.lines;
121 } else { 121 } else {
122 skip_stdout = config.stdout_lines_to_ignore; 122 skip_stdout = config.stdout_lines_to_ignore;
123 } 123 }
124 124
125 size_t skip_stderr = 0; 125 size_t skip_stderr = 0;
126 if (config.skip_stderr) { /* --skip-stderr specified without argument */ 126 if (config.skip_stderr) { /* --skip-stderr specified without argument */
127 skip_stderr = child_result.stderr.lines; 127 skip_stderr = child_result.err.lines;
128 } else { 128 } else {
129 skip_stderr = config.sterr_lines_to_ignore; 129 skip_stderr = config.sterr_lines_to_ignore;
130 } 130 }
131 131
132 /* Allow UNKNOWN or WARNING state for (non-skipped) output found on stderr */ 132 /* Allow UNKNOWN or WARNING state for (non-skipped) output found on stderr */
133 if (child_result.stderr.lines > skip_stderr && 133 if (child_result.err.lines > skip_stderr &&
134 (config.unknown_on_stderr || config.warn_on_stderr)) { 134 (config.unknown_on_stderr || config.warn_on_stderr)) {
135 mp_subcheck sc_stderr = mp_subcheck_init(); 135 mp_subcheck sc_stderr = mp_subcheck_init();
136 xasprintf(&sc_stderr.output, "remote command execution failed: %s", 136 xasprintf(&sc_stderr.output, "remote command execution failed: %s",
137 child_result.stderr.line[skip_stderr]); 137 child_result.err.line[skip_stderr]);
138 138
139 if (config.unknown_on_stderr) { 139 if (config.unknown_on_stderr) {
140 sc_stderr = mp_set_subcheck_state(sc_stderr, STATE_UNKNOWN); 140 sc_stderr = mp_set_subcheck_state(sc_stderr, STATE_UNKNOWN);
@@ -154,10 +154,10 @@ int main(int argc, char **argv) {
154 mp_subcheck sc_active_check = mp_subcheck_init(); 154 mp_subcheck sc_active_check = mp_subcheck_init();
155 xasprintf(&sc_active_check.output, "command stdout:"); 155 xasprintf(&sc_active_check.output, "command stdout:");
156 156
157 if (child_result.stdout.lines > skip_stdout) { 157 if (child_result.out.lines > skip_stdout) {
158 for (size_t i = skip_stdout; i < child_result.stdout.lines; i++) { 158 for (size_t i = skip_stdout; i < child_result.out.lines; i++) {
159 xasprintf(&sc_active_check.output, "%s\n%s", sc_active_check.output, 159 xasprintf(&sc_active_check.output, "%s\n%s", sc_active_check.output,
160 child_result.stdout.line[i]); 160 child_result.out.line[i]);
161 } 161 }
162 } else { 162 } else {
163 xasprintf(&sc_active_check.output, "remote command '%s' returned status %d", 163 xasprintf(&sc_active_check.output, "remote command '%s' returned status %d",
@@ -209,10 +209,10 @@ int main(int argc, char **argv) {
209 char *status_text; 209 char *status_text;
210 int cresult; 210 int cresult;
211 mp_subcheck sc_parse_passive = mp_subcheck_init(); 211 mp_subcheck sc_parse_passive = mp_subcheck_init();
212 for (size_t i = skip_stdout; i < child_result.stdout.lines; i++) { 212 for (size_t i = skip_stdout; i < child_result.out.lines; i++) {
213 status_text = child_result.stdout.line[i++]; 213 status_text = child_result.out.line[i++];
214 if (i == child_result.stdout.lines || 214 if (i == child_result.out.lines ||
215 strstr(child_result.stdout.line[i], "STATUS CODE: ") == NULL) { 215 strstr(child_result.out.line[i], "STATUS CODE: ") == NULL) {
216 216
217 sc_parse_passive = mp_set_subcheck_state(sc_parse_passive, STATE_UNKNOWN); 217 sc_parse_passive = mp_set_subcheck_state(sc_parse_passive, STATE_UNKNOWN);
218 xasprintf(&sc_parse_passive.output, "failed to parse output"); 218 xasprintf(&sc_parse_passive.output, "failed to parse output");
@@ -221,7 +221,7 @@ int main(int argc, char **argv) {
221 } 221 }
222 222
223 if (config.service[commands] && status_text && 223 if (config.service[commands] && status_text &&
224 sscanf(child_result.stdout.line[i], "STATUS CODE: %d", &cresult) == 1) { 224 sscanf(child_result.out.line[i], "STATUS CODE: %d", &cresult) == 1) {
225 fprintf(output_file, "[%d] PROCESS_SERVICE_CHECK_RESULT;%s;%s;%d;%s\n", (int)local_time, 225 fprintf(output_file, "[%d] PROCESS_SERVICE_CHECK_RESULT;%s;%s;%d;%s\n", (int)local_time,
226 config.host_shortname, config.service[commands++], cresult, status_text); 226 config.host_shortname, config.service[commands++], cresult, status_text);
227 } 227 }
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c
index e806ad29..e8c35f58 100644
--- a/plugins/check_smtp.c
+++ b/plugins/check_smtp.c
@@ -37,7 +37,6 @@
37#include "base64.h" 37#include "base64.h"
38#include "regex.h" 38#include "regex.h"
39 39
40#include <bits/getopt_ext.h>
41#include <ctype.h> 40#include <ctype.h>
42#include <string.h> 41#include <string.h>
43#include "check_smtp.d/config.h" 42#include "check_smtp.d/config.h"