exec plugin: Set the “COLLECTD_INTERVAL” and “COLLECTD_HOSTNAME” environment variables.
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Tue, 15 Sep 2009 13:18:40 +0000 (15:18 +0200)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Tue, 15 Sep 2009 13:18:40 +0000 (15:18 +0200)
src/exec.c

index 4405985..bbd23df 100644 (file)
@@ -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 */
   }