Module: monitoring-plugins Branch: rename_output_to_cmd_output Commit: 36f4495deee8611f2fc4c62e54616d52f5c25979 Author: RincewindsHat <12514511+rincewinds...@users.noreply.github.com> Date: Sat Mar 26 16:31:52 2022 +0100 URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=36f4495
Rename output to cmd_output --- lib/utils_cmd.c | 21 ++++++++++----------- lib/utils_cmd.h | 12 +++++++----- plugins/check_apt.c | 4 ++-- plugins/check_by_ssh.c | 2 +- plugins/check_dig.c | 2 +- plugins/check_dns.c | 2 +- plugins/check_load.c | 2 +- plugins/check_nagios.c | 2 +- plugins/check_procs.c | 2 +- plugins/check_snmp.c | 2 +- plugins/negate.c | 2 +- plugins/runcmd.c | 10 +++++----- plugins/runcmd.h | 2 +- 13 files changed, 33 insertions(+), 32 deletions(-) diff --git a/lib/utils_cmd.c b/lib/utils_cmd.c index 795840d..2dc5deb 100644 --- a/lib/utils_cmd.c +++ b/lib/utils_cmd.c @@ -70,7 +70,7 @@ extern char **environ; static int _cmd_open (char *const *, int *, int *) __attribute__ ((__nonnull__ (1, 2, 3))); -static int _cmd_fetch_output (int, output *, int) +static int _cmd_fetch_output (int, cmd_output *, int) __attribute__ ((__nonnull__ (2))); static int _cmd_close (int); @@ -196,7 +196,7 @@ _cmd_close (int fd) static int -_cmd_fetch_output (int fd, output * op, int flags) +_cmd_fetch_output (int fd, cmd_output * op, int flags) { size_t len = 0, i = 0, lineno = 0; size_t rsf = 6, ary_size = 0; /* rsf = right shift factor, dec'ed uncond once */ @@ -267,9 +267,8 @@ _cmd_fetch_output (int fd, output * op, int flags) int -cmd_run (const char *cmdstring, output * out, output * err, int flags) +cmd_run (const char *cmdstring, cmd_output * out, cmd_output * err, int flags) { - int fd, pfd_out[2], pfd_err[2]; int i = 0, argc; size_t cmdlen; char **argv = NULL; @@ -281,9 +280,9 @@ cmd_run (const char *cmdstring, output * out, output * err, int flags) /* initialize the structs */ if (out) - memset (out, 0, sizeof (output)); + memset (out, 0, sizeof (cmd_output)); if (err) - memset (err, 0, sizeof (output)); + memset (err, 0, sizeof (cmd_output)); /* make copy of command string so strtok() doesn't silently modify it */ /* (the calling program may want to access it later) */ @@ -342,15 +341,15 @@ cmd_run (const char *cmdstring, output * out, output * err, int flags) } int -cmd_run_array (char *const *argv, output * out, output * err, int flags) +cmd_run_array (char *const *argv, cmd_output * out, cmd_output * err, int flags) { int fd, pfd_out[2], pfd_err[2]; /* initialize the structs */ if (out) - memset (out, 0, sizeof (output)); + memset (out, 0, sizeof (cmd_output)); if (err) - memset (err, 0, sizeof (output)); + memset (err, 0, sizeof (cmd_output)); if ((fd = _cmd_open (argv, pfd_out, pfd_err)) == -1) die (STATE_UNKNOWN, _("Could not open pipe: %s\n"), argv[0]); @@ -364,11 +363,11 @@ cmd_run_array (char *const *argv, output * out, output * err, int flags) } int -cmd_file_read ( char *filename, output *out, int flags) +cmd_file_read ( char *filename, cmd_output *out, int flags) { int fd; if(out) - memset (out, 0, sizeof(output)); + memset (out, 0, sizeof(cmd_output)); if ((fd = open(filename, O_RDONLY)) == -1) { die( STATE_UNKNOWN, _("Error opening %s: %s"), filename, strerror(errno) ); diff --git a/lib/utils_cmd.h b/lib/utils_cmd.h index 6f3aeb8..b37c771 100644 --- a/lib/utils_cmd.h +++ b/lib/utils_cmd.h @@ -7,8 +7,10 @@ * */ +#include <sys/types.h> + /** types **/ -struct output +struct cmd_output { char *buf; /* output buffer */ size_t buflen; /* output buffer content length */ @@ -17,12 +19,12 @@ struct output size_t lines; /* lines of output */ }; -typedef struct output output; +typedef struct cmd_output cmd_output; /** prototypes **/ -int cmd_run (const char *, output *, output *, int); -int cmd_run_array (char *const *, output *, output *, int); -int cmd_file_read (char *, output *, int); +int cmd_run (const char *, cmd_output *, cmd_output *, int); +int cmd_run_array (char *const *, cmd_output *, cmd_output *, int); +int cmd_file_read (char *, cmd_output *, int); /* only multi-threaded plugins need to bother with this */ void cmd_init (void); diff --git a/plugins/check_apt.c b/plugins/check_apt.c index d7be575..731aab8 100644 --- a/plugins/check_apt.c +++ b/plugins/check_apt.c @@ -252,7 +252,7 @@ int process_arguments (int argc, char **argv) { /* run an apt-get upgrade */ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkglist){ int i=0, result=STATE_UNKNOWN, regres=0, pc=0, spc=0; - struct output chld_out, chld_err; + struct cmd_output chld_out, chld_err; regex_t ireg, ereg, sreg; char *cmdline=NULL, rerrbuf[64]; @@ -368,7 +368,7 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg /* run an apt-get update (needs root) */ int run_update(void){ int i=0, result=STATE_UNKNOWN; - struct output chld_out, chld_err; + struct cmd_output chld_out, chld_err; char *cmdline; /* run the upgrade */ diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c index 39d4907..193657c 100644 --- a/plugins/check_by_ssh.c +++ b/plugins/check_by_ssh.c @@ -70,7 +70,7 @@ main (int argc, char **argv) int i; time_t local_time; FILE *fp = NULL; - output chld_out, chld_err; + cmd_output chld_out, chld_err; remotecmd = ""; comm_append(SSH_COMMAND); diff --git a/plugins/check_dig.c b/plugins/check_dig.c index 5d85ae2..2b8b04d 100644 --- a/plugins/check_dig.c +++ b/plugins/check_dig.c @@ -67,7 +67,7 @@ int main (int argc, char **argv) { char *command_line; - output chld_out, chld_err; + cmd_output chld_out, chld_err; char *msg = NULL; size_t i; char *t; diff --git a/plugins/check_dns.c b/plugins/check_dns.c index 9de6caf..167dc4f 100644 --- a/plugins/check_dns.c +++ b/plugins/check_dns.c @@ -86,7 +86,7 @@ main (int argc, char **argv) long microsec; struct timeval tv; int parse_address = FALSE; /* This flag scans for Address: but only after Name: */ - output chld_out, chld_err; + cmd_output chld_out, chld_err; size_t i; int is_nxdomain = FALSE; diff --git a/plugins/check_load.c b/plugins/check_load.c index 0e4de54..fdfa1da 100644 --- a/plugins/check_load.c +++ b/plugins/check_load.c @@ -372,7 +372,7 @@ int cmpstringp(const void *p1, const void *p2) { static int print_top_consuming_processes() { int i = 0; - struct output chld_out, chld_err; + struct cmd_output chld_out, chld_err; if(np_runcmd(PS_COMMAND, &chld_out, &chld_err, 0) != 0){ fprintf(stderr, _("'%s' exited with non-zero status.\n"), PS_COMMAND); return STATE_UNKNOWN; diff --git a/plugins/check_nagios.c b/plugins/check_nagios.c index 40d68f0..d58a2d5 100644 --- a/plugins/check_nagios.c +++ b/plugins/check_nagios.c @@ -77,7 +77,7 @@ main (int argc, char **argv) int expected_cols = PS_COLS - 1; const char *zombie = "Z"; char *temp_string; - output chld_out, chld_err; + cmd_output chld_out, chld_err; size_t i; setlocale (LC_ALL, ""); diff --git a/plugins/check_procs.c b/plugins/check_procs.c index a025ee8..931d3dc 100644 --- a/plugins/check_procs.c +++ b/plugins/check_procs.c @@ -152,7 +152,7 @@ main (int argc, char **argv) int i = 0, j = 0; int result = STATE_UNKNOWN; int ret = 0; - output chld_out, chld_err; + cmd_output chld_out, chld_err; setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index bd13e57..205f7ee 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c @@ -196,7 +196,7 @@ main (int argc, char **argv) char *th_warn=NULL; char *th_crit=NULL; char type[8] = ""; - output chld_out, chld_err; + struct cmd_output chld_out, chld_err; char *previous_string=NULL; char *ap=NULL; char *state_string=NULL; diff --git a/plugins/negate.c b/plugins/negate.c index 50f62d3..f3d0c37 100644 --- a/plugins/negate.c +++ b/plugins/negate.c @@ -62,7 +62,7 @@ main (int argc, char **argv) int result = STATE_UNKNOWN; char *sub; char **command_line; - output chld_out, chld_err; + cmd_output chld_out, chld_err; int i; setlocale (LC_ALL, ""); diff --git a/plugins/runcmd.c b/plugins/runcmd.c index a7155d2..8919a9f 100644 --- a/plugins/runcmd.c +++ b/plugins/runcmd.c @@ -71,7 +71,7 @@ static pid_t *np_pids = NULL; static int np_runcmd_open(const char *, int *, int *) __attribute__((__nonnull__(1, 2, 3))); -static int np_fetch_output(int, output *, int) +static int np_fetch_output(int, cmd_output *, int) __attribute__((__nonnull__(2))); static int np_runcmd_close(int); @@ -253,7 +253,7 @@ runcmd_timeout_alarm_handler (int signo) static int -np_fetch_output(int fd, output *op, int flags) +np_fetch_output(int fd, cmd_output *op, int flags) { size_t len = 0, i = 0, lineno = 0; size_t rsf = 6, ary_size = 0; /* rsf = right shift factor, dec'ed uncond once */ @@ -322,13 +322,13 @@ np_fetch_output(int fd, output *op, int flags) int -np_runcmd(const char *cmd, output *out, output *err, int flags) +np_runcmd(const char *cmd, cmd_output *out, cmd_output *err, int flags) { int fd, pfd_out[2], pfd_err[2]; /* initialize the structs */ - if(out) memset(out, 0, sizeof(output)); - if(err) memset(err, 0, sizeof(output)); + if(out) memset(out, 0, sizeof(cmd_output)); + if(err) memset(err, 0, sizeof(cmd_output)); if((fd = np_runcmd_open(cmd, pfd_out, pfd_err)) == -1) die (STATE_UNKNOWN, _("Could not open pipe: %s\n"), cmd); diff --git a/plugins/runcmd.h b/plugins/runcmd.h index 2dcdadf..14dde58 100644 --- a/plugins/runcmd.h +++ b/plugins/runcmd.h @@ -28,7 +28,7 @@ #include "utils_cmd.h" /* for the "output" type */ /** prototypes **/ -int np_runcmd(const char *, output *, output *, int); +int np_runcmd(const char *, cmd_output *, cmd_output *, int); void runcmd_timeout_alarm_handler(int) __attribute__((__noreturn__));