From: Florian Forster Date: Tue, 15 Sep 2009 13:18:40 +0000 (+0200) Subject: exec plugin: Set the “COLLECTD_INTERVAL” and “COLLECTD_HOSTNAME” environment variables. X-Git-Tag: collectd-4.9.0~84 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=5c3c4f66d70e6b1a290161900f4f5dd4a4b1ff9b;p=collectd.git exec plugin: Set the “COLLECTD_INTERVAL” and “COLLECTD_HOSTNAME” environment variables. --- diff --git a/src/exec.c b/src/exec.c index 44059856..bbd23df1 100644 --- a/src/exec.c +++ b/src/exec.c @@ -265,6 +265,17 @@ static int exec_config (oconfig_item_t *ci) /* {{{ */ return (0); } /* int exec_config }}} */ +static void set_environment (void) /* {{{ */ +{ + char buffer[1024]; + + ssnprintf (buffer, sizeof (buffer), "%i", interval_g); + setenv ("COLLECTD_INTERVAL", buffer, /* overwrite = */ 1); + + ssnprintf (buffer, sizeof (buffer), "%s", hostname_g); + setenv ("COLLECTD_HOSTNAME", buffer, /* overwrite = */ 1); +} /* }}} void set_environment */ + static void exec_child (program_list_t *pl) /* {{{ */ { int status; @@ -468,6 +479,7 @@ static int fork_child (program_list_t *pl, int *fd_in, int *fd_out, int *fd_err) close (fd_pipe_err[1]); } + set_environment (); exec_child (pl); /* does not return */ }