X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fexec.c;h=da6e367d633dc3019849c65028c4ad89946dbb9f;hb=cd35a6a4528cf78383266fbae770b9c7161fda25;hp=681b94d67c8b28a334b74c1078389540aacdc570;hpb=070563c1ac6bf489cb13095ed30a6d290b98ac75;p=collectd.git diff --git a/src/exec.c b/src/exec.c index 681b94d6..da6e367d 100644 --- a/src/exec.c +++ b/src/exec.c @@ -269,11 +269,21 @@ static void set_environment (void) /* {{{ */ { char buffer[1024]; - ssnprintf (buffer, sizeof (buffer), "%i", interval_g); +#ifdef HAVE_SETENV + ssnprintf (buffer, sizeof (buffer), "%.3f", + CDTIME_T_TO_DOUBLE (plugin_get_interval ())); setenv ("COLLECTD_INTERVAL", buffer, /* overwrite = */ 1); ssnprintf (buffer, sizeof (buffer), "%s", hostname_g); setenv ("COLLECTD_HOSTNAME", buffer, /* overwrite = */ 1); +#else + ssnprintf (buffer, sizeof (buffer), "COLLECTD_INTERVAL=%.3f", + CDTIME_T_TO_DOUBLE (plugin_get_interval ())); + putenv (buffer); + + ssnprintf (buffer, sizeof (buffer), "COLLECTD_HOSTNAME=%s", hostname_g); + putenv (buffer); +#endif } /* }}} void set_environment */ __attribute__((noreturn)) @@ -529,12 +539,9 @@ static int parse_line (char *buffer) /* {{{ */ return (handle_putnotif (stdout, buffer)); else { - /* For backwards compatibility */ - char tmp[1220]; - /* Let's annoy the user a bit.. */ - INFO ("exec plugin: Prepending `PUTVAL' to this line: %s", buffer); - ssnprintf (tmp, sizeof (tmp), "PUTVAL %s", buffer); - return (handle_putval (stdout, tmp)); + ERROR ("exec plugin: Unable to parse command, ignoring line: \"%s\"", + buffer); + return (-1); } } /* int parse_line }}} */ @@ -723,8 +730,8 @@ static void *exec_notification_one (void *arg) /* {{{ */ fprintf (fh, "Severity: %s\n" - "Time: %u\n", - severity, (unsigned int) n->time); + "Time: %.3f\n", + severity, CDTIME_T_TO_DOUBLE (n->time)); /* Print the optional fields */ if (strlen (n->host) > 0) @@ -807,7 +814,7 @@ static int exec_read (void) /* {{{ */ pthread_attr_init (&attr); pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); - pthread_create (&t, &attr, exec_read_one, (void *) pl); + plugin_thread_create (&t, &attr, exec_read_one, (void *) pl); } /* for (pl) */ return (0); @@ -850,7 +857,7 @@ static int exec_notification (const notification_t *n, /* {{{ */ pthread_attr_init (&attr); pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); - pthread_create (&t, &attr, exec_notification_one, (void *) pln); + plugin_thread_create (&t, &attr, exec_notification_one, (void *) pln); } /* for (pl) */ return (0);