mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-04-15 22:00:06 -04:00
Merge 5472403d6a into a71ce15308
This commit is contained in:
commit
bcd601eb65
3 changed files with 26 additions and 2 deletions
|
|
@ -61,6 +61,8 @@ static inline char *fmt_subcheck_perfdata(mp_subcheck check) {
|
|||
mp_check mp_check_init(void) {
|
||||
mp_check check = {
|
||||
.evaluation_function = &mp_eval_check_default,
|
||||
.default_output_override = NULL,
|
||||
.default_output_override_content = NULL,
|
||||
};
|
||||
return check;
|
||||
}
|
||||
|
|
@ -283,6 +285,11 @@ char *mp_fmt_output(mp_check check) {
|
|||
|
||||
switch (output_format) {
|
||||
case MP_FORMAT_MULTI_LINE: {
|
||||
if (check.default_output_override != NULL) {
|
||||
result = check.default_output_override(check.default_output_override_content);
|
||||
break;
|
||||
}
|
||||
|
||||
if (check.summary == NULL) {
|
||||
check.summary = get_subcheck_summary(check);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,6 +70,10 @@ struct mp_check {
|
|||
|
||||
// the evaluation_functions computes the state of check
|
||||
mp_state_enum (*evaluation_function)(mp_check);
|
||||
|
||||
// override for the default output format
|
||||
char *(*default_output_override)(void *);
|
||||
void *default_output_override_content;
|
||||
};
|
||||
|
||||
mp_check mp_check_init(void);
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ const char *email = "devel@monitoring-plugins.org";
|
|||
# define NP_MAXARGS 1024
|
||||
#endif
|
||||
|
||||
char *check_by_ssh_output_override(void *remote_output) { return ((char *)remote_output); }
|
||||
|
||||
typedef struct {
|
||||
int errorcode;
|
||||
check_by_ssh_config config;
|
||||
|
|
@ -155,10 +157,21 @@ int main(int argc, char **argv) {
|
|||
xasprintf(&sc_active_check.output, "command stdout:");
|
||||
|
||||
if (child_result.out.lines > skip_stdout) {
|
||||
|
||||
char *remote_command_output = NULL;
|
||||
for (size_t i = skip_stdout; i < child_result.out.lines; i++) {
|
||||
xasprintf(&sc_active_check.output, "%s\n%s", sc_active_check.output,
|
||||
child_result.out.line[i]);
|
||||
if (i == skip_stdout) {
|
||||
// first iteration
|
||||
xasprintf(&remote_command_output, "%s", child_result.out.line[i]);
|
||||
} else {
|
||||
xasprintf(&remote_command_output, "%s\n%s", remote_command_output,
|
||||
child_result.out.line[i]);
|
||||
}
|
||||
}
|
||||
|
||||
sc_active_check.output = remote_command_output;
|
||||
overall.default_output_override_content = remote_command_output;
|
||||
overall.default_output_override = check_by_ssh_output_override;
|
||||
} else {
|
||||
xasprintf(&sc_active_check.output, "remote command '%s' returned status %d",
|
||||
config.remotecmd, child_result.cmd_error_code);
|
||||
|
|
|
|||
Loading…
Reference in a new issue