2007-09-21 19:01:28 -04:00
|
|
|
#ifndef _UTILS_CMD_
|
|
|
|
|
#define _UTILS_CMD_
|
|
|
|
|
|
2023-10-15 12:17:36 -04:00
|
|
|
/*
|
2014-01-21 10:19:20 -05:00
|
|
|
* Header file for Monitoring Plugins utils_cmd.c
|
2023-10-15 12:17:36 -04:00
|
|
|
*
|
2007-09-21 19:01:28 -04:00
|
|
|
*/
|
2025-09-15 08:06:55 -04:00
|
|
|
#include "../config.h"
|
|
|
|
|
#include <stddef.h>
|
2007-09-21 19:01:28 -04:00
|
|
|
|
|
|
|
|
/** types **/
|
2025-09-15 08:06:55 -04:00
|
|
|
typedef struct {
|
2007-09-21 19:01:28 -04:00
|
|
|
char *buf; /* output buffer */
|
|
|
|
|
size_t buflen; /* output buffer content length */
|
|
|
|
|
char **line; /* array of lines (points to buf) */
|
|
|
|
|
size_t lines; /* lines of output */
|
2025-09-15 08:06:55 -04:00
|
|
|
} output;
|
2007-09-21 19:01:28 -04:00
|
|
|
|
|
|
|
|
/** prototypes **/
|
2024-10-17 11:57:50 -04:00
|
|
|
int cmd_run(const char *, output *, output *, int);
|
|
|
|
|
int cmd_run_array(char *const *, output *, output *, int);
|
2025-05-09 04:49:02 -04:00
|
|
|
int cmd_file_read(const char *, output *, int);
|
2007-09-21 19:01:28 -04:00
|
|
|
|
2025-11-16 08:26:41 -05:00
|
|
|
typedef struct {
|
|
|
|
|
int error_code;
|
|
|
|
|
int cmd_error_code;
|
2025-12-11 04:53:07 -05:00
|
|
|
output out;
|
|
|
|
|
output err;
|
2025-11-16 08:26:41 -05:00
|
|
|
} cmd_run_result;
|
|
|
|
|
cmd_run_result cmd_run2(const char *cmd, int flags);
|
|
|
|
|
cmd_run_result cmd_run_array2(char * const *cmd, int flags);
|
|
|
|
|
|
2007-09-21 19:01:28 -04:00
|
|
|
/* only multi-threaded plugins need to bother with this */
|
2024-10-17 11:57:50 -04:00
|
|
|
void cmd_init(void);
|
2007-09-21 19:01:28 -04:00
|
|
|
#define CMD_INIT cmd_init()
|
|
|
|
|
|
|
|
|
|
/* possible flags for cmd_run()'s fourth argument */
|
2024-10-17 11:57:50 -04:00
|
|
|
#define CMD_NO_ARRAYS 0x01 /* don't populate arrays at all */
|
|
|
|
|
#define CMD_NO_ASSOC 0x02 /* output.line won't point to buf */
|
2019-02-15 04:36:28 -05:00
|
|
|
|
2024-10-17 11:57:50 -04:00
|
|
|
void timeout_alarm_handler(int);
|
2019-02-15 04:36:28 -05:00
|
|
|
|
2007-09-21 19:01:28 -04:00
|
|
|
#endif /* _UTILS_CMD_ */
|