diff options
| -rw-r--r-- | lib/output.c | 7 | ||||
| -rw-r--r-- | lib/output.h | 4 | ||||
| -rw-r--r-- | plugins/Makefile.am | 2 | ||||
| -rw-r--r-- | plugins/check_by_ssh.c | 17 | ||||
| -rw-r--r-- | plugins/check_snmp.c | 2 | ||||
| -rw-r--r-- | plugins/common.h | 2 |
6 files changed, 30 insertions, 4 deletions
diff --git a/lib/output.c b/lib/output.c index bfd43195..54d505d9 100644 --- a/lib/output.c +++ b/lib/output.c | |||
| @@ -61,6 +61,8 @@ static inline char *fmt_subcheck_perfdata(mp_subcheck check) { | |||
| 61 | mp_check mp_check_init(void) { | 61 | mp_check mp_check_init(void) { |
| 62 | mp_check check = { | 62 | mp_check check = { |
| 63 | .evaluation_function = &mp_eval_check_default, | 63 | .evaluation_function = &mp_eval_check_default, |
| 64 | .default_output_override = NULL, | ||
| 65 | .default_output_override_content = NULL, | ||
| 64 | }; | 66 | }; |
| 65 | return check; | 67 | return check; |
| 66 | } | 68 | } |
| @@ -283,6 +285,11 @@ char *mp_fmt_output(mp_check check) { | |||
| 283 | 285 | ||
| 284 | switch (output_format) { | 286 | switch (output_format) { |
| 285 | case MP_FORMAT_MULTI_LINE: { | 287 | case MP_FORMAT_MULTI_LINE: { |
| 288 | if (check.default_output_override != NULL) { | ||
| 289 | result = check.default_output_override(check.default_output_override_content); | ||
| 290 | break; | ||
| 291 | } | ||
| 292 | |||
| 286 | if (check.summary == NULL) { | 293 | if (check.summary == NULL) { |
| 287 | check.summary = get_subcheck_summary(check); | 294 | check.summary = get_subcheck_summary(check); |
| 288 | } | 295 | } |
diff --git a/lib/output.h b/lib/output.h index c63c8e3f..f5011268 100644 --- a/lib/output.h +++ b/lib/output.h | |||
| @@ -70,6 +70,10 @@ struct mp_check { | |||
| 70 | 70 | ||
| 71 | // the evaluation_functions computes the state of check | 71 | // the evaluation_functions computes the state of check |
| 72 | mp_state_enum (*evaluation_function)(mp_check); | 72 | mp_state_enum (*evaluation_function)(mp_check); |
| 73 | |||
| 74 | // override for the default output format | ||
| 75 | char *(*default_output_override)(void *); | ||
| 76 | void *default_output_override_content; | ||
| 73 | }; | 77 | }; |
| 74 | 78 | ||
| 75 | mp_check mp_check_init(void); | 79 | mp_check mp_check_init(void); |
diff --git a/plugins/Makefile.am b/plugins/Makefile.am index a35f273e..2bea8fc0 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am | |||
| @@ -166,7 +166,7 @@ check_real_LDADD = $(NETLIBS) | |||
| 166 | check_snmp_SOURCES = check_snmp.c check_snmp.d/check_snmp_helpers.c | 166 | check_snmp_SOURCES = check_snmp.c check_snmp.d/check_snmp_helpers.c |
| 167 | check_snmp_LDADD = $(BASEOBJS) | 167 | check_snmp_LDADD = $(BASEOBJS) |
| 168 | check_snmp_LDFLAGS = $(AM_LDFLAGS) -lm `net-snmp-config --libs` | 168 | check_snmp_LDFLAGS = $(AM_LDFLAGS) -lm `net-snmp-config --libs` |
| 169 | check_snmp_CFLAGS = $(AM_CFLAGS) `net-snmp-config --cflags` | 169 | check_snmp_CFLAGS = $(AM_CFLAGS) `net-snmp-config --cflags | sed 's/-Werror=declaration-after-statement//'` |
| 170 | check_smtp_LDADD = $(SSLOBJS) | 170 | check_smtp_LDADD = $(SSLOBJS) |
| 171 | check_ssh_LDADD = $(NETLIBS) | 171 | check_ssh_LDADD = $(NETLIBS) |
| 172 | check_swap_SOURCES = check_swap.c check_swap.d/swap.c | 172 | check_swap_SOURCES = check_swap.c check_swap.d/swap.c |
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c index 7ffa0ded..4d0c8e7d 100644 --- a/plugins/check_by_ssh.c +++ b/plugins/check_by_ssh.c | |||
| @@ -41,6 +41,8 @@ const char *email = "devel@monitoring-plugins.org"; | |||
| 41 | # define NP_MAXARGS 1024 | 41 | # define NP_MAXARGS 1024 |
| 42 | #endif | 42 | #endif |
| 43 | 43 | ||
| 44 | char *check_by_ssh_output_override(void *remote_output) { return ((char *)remote_output); } | ||
| 45 | |||
| 44 | typedef struct { | 46 | typedef struct { |
| 45 | int errorcode; | 47 | int errorcode; |
| 46 | check_by_ssh_config config; | 48 | check_by_ssh_config config; |
| @@ -155,10 +157,21 @@ int main(int argc, char **argv) { | |||
| 155 | xasprintf(&sc_active_check.output, "command stdout:"); | 157 | xasprintf(&sc_active_check.output, "command stdout:"); |
| 156 | 158 | ||
| 157 | if (child_result.out.lines > skip_stdout) { | 159 | if (child_result.out.lines > skip_stdout) { |
| 160 | |||
| 161 | char *remote_command_output = NULL; | ||
| 158 | for (size_t i = skip_stdout; i < child_result.out.lines; i++) { | 162 | 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, | 163 | if (i == skip_stdout) { |
| 160 | child_result.out.line[i]); | 164 | // first iteration |
| 165 | xasprintf(&remote_command_output, "%s", child_result.out.line[i]); | ||
| 166 | } else { | ||
| 167 | xasprintf(&remote_command_output, "%s\n%s", remote_command_output, | ||
| 168 | child_result.out.line[i]); | ||
| 169 | } | ||
| 161 | } | 170 | } |
| 171 | |||
| 172 | sc_active_check.output = remote_command_output; | ||
| 173 | overall.default_output_override_content = remote_command_output; | ||
| 174 | overall.default_output_override = check_by_ssh_output_override; | ||
| 162 | } else { | 175 | } else { |
| 163 | xasprintf(&sc_active_check.output, "remote command '%s' returned status %d", | 176 | xasprintf(&sc_active_check.output, "remote command '%s' returned status %d", |
| 164 | config.remotecmd, child_result.cmd_error_code); | 177 | config.remotecmd, child_result.cmd_error_code); |
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index f470d222..1746fd79 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c | |||
| @@ -116,6 +116,7 @@ gen_state_string_type gen_state_string(check_snmp_state_entry *entries, size_t n | |||
| 116 | break; | 116 | break; |
| 117 | case ASN_FLOAT: | 117 | case ASN_FLOAT: |
| 118 | printf("Type FLOAT\n"); | 118 | printf("Type FLOAT\n"); |
| 119 | break; | ||
| 119 | case ASN_DOUBLE: | 120 | case ASN_DOUBLE: |
| 120 | printf("Type DOUBLE\n"); | 121 | printf("Type DOUBLE\n"); |
| 121 | break; | 122 | break; |
| @@ -217,6 +218,7 @@ recover_state_data_type recover_state_data(char *state_string, idx_t state_strin | |||
| 217 | break; | 218 | break; |
| 218 | case ASN_FLOAT: | 219 | case ASN_FLOAT: |
| 219 | printf("Type FLOAT\n"); | 220 | printf("Type FLOAT\n"); |
| 221 | break; | ||
| 220 | case ASN_DOUBLE: | 222 | case ASN_DOUBLE: |
| 221 | printf("Type DOUBLE\n"); | 223 | printf("Type DOUBLE\n"); |
| 222 | break; | 224 | break; |
diff --git a/plugins/common.h b/plugins/common.h index ef888d08..b3053486 100644 --- a/plugins/common.h +++ b/plugins/common.h | |||
| @@ -193,7 +193,7 @@ enum { | |||
| 193 | */ | 193 | */ |
| 194 | #include "../gl/gettext.h" | 194 | #include "../gl/gettext.h" |
| 195 | #define _(String) gettext(String) | 195 | #define _(String) gettext(String) |
| 196 | #if !ENABLE_NLS | 196 | #if !defined(ENABLE_NLS) || !ENABLE_NLS |
| 197 | # undef textdomain | 197 | # undef textdomain |
| 198 | # define textdomain(Domainname) /* empty */ | 198 | # define textdomain(Domainname) /* empty */ |
| 199 | # undef bindtextdomain | 199 | # undef bindtextdomain |
