From 5c3c4f66d70e6b1a290161900f4f5dd4a4b1ff9b Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Tue, 15 Sep 2009 15:18:40 +0200 Subject: [PATCH] =?utf8?q?exec=20plugin:=20Set=20the=20=E2=80=9CCOLLECTD?= =?utf8?q?=5FINTERVAL=E2=80=9D=20and=20=E2=80=9CCOLLECTD=5FHOSTNAME?= =?utf8?q?=E2=80=9D=20environment=20variables.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/exec.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 */ } -- 2.30.2