src/plugin.[ch]: Store the hostname in a global variable to minimize calls to `gethos...
[collectd.git] / src / traffic.c
index 59b59e8..5c5e4f7 100644 (file)
@@ -237,14 +237,7 @@ static void if_submit (const char *dev, const char *type,
        vl.values = values;
        vl.values_len = 2;
        vl.time = time (NULL);
-
-       /* FIXME: do this globally */
-       if (gethostname (vl.host, sizeof (vl.host)) != 0)
-       {
-               syslog (LOG_ERR, "load plugin: gethostname failed: %s",
-                               strerror (errno));
-               return;
-       }
+       strcpy (vl.host, hostname);
        strcpy (vl.plugin, "interface");
        strcpy (vl.plugin_instance, "");
        strncpy (vl.type_instance, dev, sizeof (vl.type_instance));