From 2d897a731bd23f7a33b89e7b7e3004b6b26b5a94 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Wed, 28 Feb 2007 10:41:55 +0100 Subject: [PATCH] Introduce two global variables: `hostname_g' and `interval_g'. hostname_g: Hostname we're running on. May be set in the configfile with the `Hostname'-option. This replaces the global `hostname'-variable exported by `plugin.c'. interval_g: Interval in which we query the read plugins. This replaces the `COLLECTD_STEP'-define and is configurable using the `Interval'-option. --- src/apache.c | 4 +-- src/apcups.c | 2 +- src/apple_sensors.c | 2 +- src/battery.c | 2 +- src/collectd.c | 77 +++++++++++++++++++++++++++++++++++++-------------- src/collectd.conf.pod | 8 ++++++ src/collectd.h | 6 ++-- src/configfile.c | 10 +++++-- src/cpu.c | 2 +- src/cpufreq.c | 2 +- src/df.c | 2 +- src/disk.c | 2 +- src/dns.c | 4 +-- src/entropy.c | 2 +- src/exec.c | 4 +-- src/hddtemp.c | 2 +- src/irq.c | 2 +- src/load.c | 2 +- src/mbmon.c | 2 +- src/memory.c | 2 +- src/multimeter.c | 2 +- src/mysql.c | 8 +++--- src/nfs.c | 2 +- src/ntpd.c | 2 +- src/ping.c | 2 +- src/plugin.c | 4 --- src/plugin.h | 2 -- src/processes.c | 4 +-- src/rrdtool.c | 13 +++++++-- src/sensors.c | 2 +- src/serial.c | 2 +- src/swap.c | 2 +- src/tape.c | 2 +- src/traffic.c | 2 +- src/wireless.c | 2 +- 35 files changed, 119 insertions(+), 71 deletions(-) diff --git a/src/apache.c b/src/apache.c index 5156ff66..973ad865 100644 --- a/src/apache.c +++ b/src/apache.c @@ -205,7 +205,7 @@ static void submit_counter (const char *type, const char *type_instance, vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "apache"); strcpy (vl.plugin_instance, ""); strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); @@ -227,7 +227,7 @@ static void submit_gauge (const char *type, const char *type_instance, vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "apache"); strcpy (vl.plugin_instance, ""); diff --git a/src/apcups.c b/src/apcups.c index 3060e18c..e23bc9e1 100644 --- a/src/apcups.c +++ b/src/apcups.c @@ -423,7 +423,7 @@ static void apc_submit_generic (char *type, char *type_inst, double value) vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "apcups"); strcpy (vl.plugin_instance, ""); strncpy (vl.type_instance, type_inst, sizeof (vl.type_instance)); diff --git a/src/apple_sensors.c b/src/apple_sensors.c index 33660a92..29d50915 100644 --- a/src/apple_sensors.c +++ b/src/apple_sensors.c @@ -118,7 +118,7 @@ static void as_submit (const char *type, const char *type_instance, vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "apple_sensors"); strcpy (vl.plugin_instance, ""); strcpy (vl.type_instance, type_instance); diff --git a/src/battery.c b/src/battery.c index e52c2c80..8a74b3db 100644 --- a/src/battery.c +++ b/src/battery.c @@ -132,7 +132,7 @@ static void battery_submit (const char *plugin_instance, const char *type, doubl vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "battery"); strcpy (vl.plugin_instance, plugin_instance); diff --git a/src/collectd.c b/src/collectd.c index ab5564ea..68a70bac 100644 --- a/src/collectd.c +++ b/src/collectd.c @@ -28,16 +28,16 @@ #include "plugin.h" #include "configfile.h" -static int loop = 0; - +/* + * Global variables + */ +char hostname_g[DATA_MAX_NAME_LEN]; +int interval_g; #if HAVE_LIBKSTAT kstat_ctl_t *kc; #endif /* HAVE_LIBKSTAT */ -/* - * exported variables - */ -time_t curtime; +static int loop = 0; static void sigIntHandler (int signal) { @@ -49,6 +49,41 @@ static void sigTermHandler (int signal) loop++; } +static int init_global_variables (void) +{ + const char *str; + + str = global_option_get ("Hostname"); + if (str != NULL) + { + strncpy (hostname_g, str, sizeof (hostname_g)); + } + else + { + if (gethostname (hostname_g, sizeof (hostname_g)) != 0) + { + fprintf (stderr, "`gethostname' failed and no " + "hostname was configured.\n"); + return (-1); + } + } + DBG ("hostname_g = %s;", hostname_g); + + str = global_option_get ("Interval"); + if (str == NULL) + str = COLLECTD_STEP; + interval_g = atoi (str); + if (interval_g <= 0) + { + fprintf (stderr, "Cannot set the interval to a correct value.\n" + "Please check your settings.\n"); + return (-1); + } + DBG ("interval_g = %i;", interval_g); + + return (0); +} /* int init_global_variables */ + static int change_basedir (const char *orig_dir) { char *dir = strdup (orig_dir); @@ -185,16 +220,10 @@ static int do_init (void) static int do_loop (void) { - int step; - struct timeval tv_now; struct timeval tv_next; struct timespec ts_wait; - step = atoi (COLLECTD_STEP); - if (step <= 0) - step = 10; - while (loop == 0) { if (gettimeofday (&tv_next, NULL) < 0) @@ -202,14 +231,11 @@ static int do_loop (void) syslog (LOG_ERR, "gettimeofday failed: %s", strerror (errno)); return (-1); } - tv_next.tv_sec += step; + tv_next.tv_sec += interval_g; #if HAVE_LIBKSTAT update_kstat (); #endif - /* `curtime' is used by many (all?) plugins as the - * data-sample-time passed to RRDTool */ - curtime = time (NULL); /* Issue all plugins */ plugin_read_all (&loop); @@ -281,7 +307,7 @@ int main (int argc, char **argv) struct sigaction sigIntAction; struct sigaction sigTermAction; char *configfile = CONFIGFILE; - const char *datadir; + const char *basedir; #if COLLECT_DAEMON struct sigaction sigChldAction; pid_t pid; @@ -349,17 +375,26 @@ int main (int argc, char **argv) * Change directory. We do this _after_ reading the config and loading * modules to relative paths work as expected. */ - if ((datadir = global_option_get ("BaseDir")) == NULL) + if ((basedir = global_option_get ("BaseDir")) == NULL) { - fprintf (stderr, "Don't have a datadir to use. This should not happen. Ever."); + fprintf (stderr, "Don't have a basedir to use. This should not happen. Ever."); return (1); } - else if (change_basedir (datadir)) + else if (change_basedir (basedir)) { - fprintf (stderr, "Error: Unable to change to directory `%s'.\n", datadir); + fprintf (stderr, "Error: Unable to change to directory `%s'.\n", basedir); return (1); } + /* + * Set global variables or, if that failes, exit. We cannot run with + * them being uninitialized. If nothing is configured, then defaults + * are being used. So this means that the user has actually done + * something wrong. + */ + if (init_global_variables () != 0) + return (1); + #if COLLECT_DAEMON /* * fork off child diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index ecf7ef68..3d387079 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -59,6 +59,14 @@ setting using the B<-P> commandline option. Sets the file to write debugging output to. This is only used if compiled with debugging enabled. It's ignored otherwise. +=item B I + +Configures the interval in which to query the read plugins. Obviously smaller +values lead to a higher system load produces by collectd, while higher values +lead to more coarse statistics. Please note that changing this value may render +your RRD-files unuseable, if you use the C. You have been +warned. + =back =head1 PLUGIN OPTIONS diff --git a/src/collectd.h b/src/collectd.h index 7784d554..c544bf5c 100644 --- a/src/collectd.h +++ b/src/collectd.h @@ -223,10 +223,8 @@ #define STATIC_ARRAY_LEN(array) (sizeof (array) / sizeof ((array)[0])) -extern time_t curtime; - -int pidfile_set (const char *file); -const char *pidfile_get (void); +extern char hostname_g[]; +extern int interval_g; /* int main (int argc, char **argv); */ diff --git a/src/configfile.c b/src/configfile.c index a8f902fd..a5ae4961 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -77,9 +77,11 @@ static int cf_value_map_num = STATIC_ARRAY_LEN (cf_value_map); static cf_global_option_t cf_global_options[] = { - {"BaseDir", NULL, PKGLOCALSTATEDIR}, - {"LogFile", NULL, LOGFILE}, - {"PIDFile", NULL, PIDFILE} + {"BaseDir", NULL, PKGLOCALSTATEDIR}, + {"LogFile", NULL, LOGFILE}, + {"PIDFile", NULL, PIDFILE}, + {"Hostname", NULL, NULL}, + {"Interval", NULL, "10"} }; static int cf_global_options_num = STATIC_ARRAY_LEN (cf_global_options); @@ -285,6 +287,8 @@ int global_option_set (const char *option, const char *value) { int i; + DBG ("option = %s; value = %s;", option, value); + for (i = 0; i < cf_global_options_num; i++) if (strcasecmp (cf_global_options[i].key, option) == 0) break; diff --git a/src/cpu.c b/src/cpu.c index 437f7587..285841e4 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -183,7 +183,7 @@ static void submit (int cpu_num, const char *type_instance, counter_t value) vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "cpu"); snprintf (vl.plugin_instance, sizeof (vl.type_instance), "%i", cpu_num); diff --git a/src/cpufreq.c b/src/cpufreq.c index e53e4952..008ef39f 100644 --- a/src/cpufreq.c +++ b/src/cpufreq.c @@ -89,7 +89,7 @@ static void cpufreq_submit (int cpu_num, double value) vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "cpufreq"); snprintf (vl.type_instance, sizeof (vl.type_instance), "%i", cpu_num); diff --git a/src/df.c b/src/df.c index dd5e1382..fde5d9ae 100644 --- a/src/df.c +++ b/src/df.c @@ -142,7 +142,7 @@ static void df_submit (char *df_name, vl.values = values; vl.values_len = 2; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "df"); strcpy (vl.plugin_instance, ""); strncpy (vl.type_instance, df_name, sizeof (vl.type_instance)); diff --git a/src/disk.c b/src/disk.c index 3cb86e7e..af7c01a6 100644 --- a/src/disk.c +++ b/src/disk.c @@ -210,7 +210,7 @@ static void disk_submit (const char *plugin_instance, vl.values = values; vl.values_len = 2; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "disk"); strncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance)); diff --git a/src/dns.c b/src/dns.c index 332ef0ea..56df1845 100644 --- a/src/dns.c +++ b/src/dns.c @@ -342,7 +342,7 @@ static void submit_counter (const char *type, const char *type_instance, vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "dns"); strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); @@ -360,7 +360,7 @@ static void submit_octets (counter_t queries, counter_t responses) vl.values = values; vl.values_len = 2; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "dns"); plugin_dispatch_values ("dns_octets", &vl); diff --git a/src/entropy.c b/src/entropy.c index 7e0a8174..68c57daf 100644 --- a/src/entropy.c +++ b/src/entropy.c @@ -52,7 +52,7 @@ static void entropy_submit (double entropy) vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "entropy"); strcpy (vl.plugin_instance, ""); strcpy (vl.type_instance, ""); diff --git a/src/exec.c b/src/exec.c index 836c881d..ee8f8bf9 100644 --- a/src/exec.c +++ b/src/exec.c @@ -136,7 +136,7 @@ static void submit_counter (const char *type_instance, counter_t value) vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "exec"); strcpy (vl.plugin_instance, ""); strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); @@ -156,7 +156,7 @@ static void submit_gauge (const char *type_instance, gauge_t value) vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "exec"); strcpy (vl.plugin_instance, ""); strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); diff --git a/src/hddtemp.c b/src/hddtemp.c index 3f37d507..03990f22 100644 --- a/src/hddtemp.c +++ b/src/hddtemp.c @@ -431,7 +431,7 @@ static void hddtemp_submit (char *type_instance, double value) vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "hddtemp"); strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); diff --git a/src/irq.c b/src/irq.c index 6e1f92ec..5826dc3d 100644 --- a/src/irq.c +++ b/src/irq.c @@ -147,7 +147,7 @@ static void irq_submit (unsigned int irq, counter_t value) vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "irq"); status = snprintf (vl.type_instance, sizeof (vl.type_instance), diff --git a/src/load.c b/src/load.c index 491a985e..4b362213 100644 --- a/src/load.c +++ b/src/load.c @@ -68,7 +68,7 @@ static void load_submit (double snum, double mnum, double lnum) vl.values = values; vl.values_len = 3; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "load"); strcpy (vl.plugin_instance, ""); strcpy (vl.type_instance, ""); diff --git a/src/mbmon.c b/src/mbmon.c index 0d9cd163..e03f2f9b 100644 --- a/src/mbmon.c +++ b/src/mbmon.c @@ -252,7 +252,7 @@ static void mbmon_submit (const char *type, const char *type_instance, vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "mbmon"); strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); diff --git a/src/memory.c b/src/memory.c index d92ecf30..38a6dc2d 100644 --- a/src/memory.c +++ b/src/memory.c @@ -123,7 +123,7 @@ static void memory_submit (long long mem_used, long long mem_buffered, vl.values = values; vl.values_len = 4; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "memory"); plugin_dispatch_values ("memory", &vl); diff --git a/src/multimeter.c b/src/multimeter.c index d1cf1903..8cb18c81 100644 --- a/src/multimeter.c +++ b/src/multimeter.c @@ -223,7 +223,7 @@ static void multimeter_submit (double value) vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "multimeter"); plugin_dispatch_values ("multimeter", &vl); diff --git a/src/mysql.c b/src/mysql.c index a928172b..a2604e40 100644 --- a/src/mysql.c +++ b/src/mysql.c @@ -190,7 +190,7 @@ static void counter_submit (const char *type, const char *type_instance, vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "mysql"); strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); @@ -213,7 +213,7 @@ static void qcache_submit (counter_t hits, counter_t inserts, vl.values = values; vl.values_len = 5; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "mysql"); plugin_dispatch_values ("mysql_qcache", &vl); @@ -233,7 +233,7 @@ static void threads_submit (gauge_t running, gauge_t connected, gauge_t cached, vl.values = values; vl.values_len = 4; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "mysql"); plugin_dispatch_values ("mysql_threads", &vl); @@ -250,7 +250,7 @@ static void traffic_submit (counter_t rx, counter_t tx) vl.values = values; vl.values_len = 2; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "mysql"); plugin_dispatch_values ("mysql_octets", &vl); diff --git a/src/nfs.c b/src/nfs.c index 1dc64b78..004c8f5e 100644 --- a/src/nfs.c +++ b/src/nfs.c @@ -205,7 +205,7 @@ static void nfs_procedures_submit (const char *plugin_instance, vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "nfs"); strncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance)); diff --git a/src/ntpd.c b/src/ntpd.c index 366c24b4..e4a230b3 100644 --- a/src/ntpd.c +++ b/src/ntpd.c @@ -326,7 +326,7 @@ static void ntpd_submit (char *type, char *type_inst, double value) vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "ntpd"); strcpy (vl.plugin_instance, ""); strncpy (vl.type_instance, type_inst, sizeof (vl.type_instance)); diff --git a/src/ping.c b/src/ping.c index 61bad09f..48cea55c 100644 --- a/src/ping.c +++ b/src/ping.c @@ -189,7 +189,7 @@ static void ping_submit (char *host, double latency) vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "ping"); strcpy (vl.plugin_instance, ""); strncpy (vl.type_instance, host, sizeof (vl.type_instance)); diff --git a/src/plugin.c b/src/plugin.c index 1a029e40..852a693e 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -50,8 +50,6 @@ static llist_t *list_data_set; static char *plugindir = NULL; -char hostname[DATA_MAX_NAME_LEN] = "localhost"; - /* * Static functions */ @@ -319,8 +317,6 @@ void plugin_init_all (void) llentry_t *le; int status; - gethostname (hostname, sizeof (hostname)); - if (list_init == NULL) return; diff --git a/src/plugin.h b/src/plugin.h index b0bdbee1..ef84a46f 100644 --- a/src/plugin.h +++ b/src/plugin.h @@ -77,8 +77,6 @@ typedef struct complain_s unsigned int delay; /* how many more iterations we still need to wait */ } complain_t; -extern char hostname[DATA_MAX_NAME_LEN]; - /* * NAME * plugin_set_dir diff --git a/src/processes.c b/src/processes.c index c22f0f6f..37d0a75e 100644 --- a/src/processes.c +++ b/src/processes.c @@ -478,7 +478,7 @@ static void ps_submit_state (const char *state, double value) vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "processes"); strcpy (vl.plugin_instance, ""); strncpy (vl.type_instance, state, sizeof (vl.type_instance)); @@ -494,7 +494,7 @@ static void ps_submit_proc_list (procstat_t *ps) vl.values = values; vl.values_len = 2; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "processes"); strncpy (vl.plugin_instance, ps->name, sizeof (vl.plugin_instance)); diff --git a/src/rrdtool.c b/src/rrdtool.c index 91be7b61..8154df9d 100644 --- a/src/rrdtool.c +++ b/src/rrdtool.c @@ -119,7 +119,8 @@ static int rra_get (char ***ret) return (-1); memset (rra_def, '\0', (rra_max + 1) * sizeof (char *)); - step = atoi (COLLECTD_STEP); + step = interval_g; + /* FIXME: Use config here */ rows = atoi (COLLECTD_ROWS); if ((step <= 0) || (rows <= 0)) @@ -277,6 +278,7 @@ static int rrd_create_file (char *filename, const data_set_t *ds) char **ds_def; int ds_num; int i, j; + char step[16]; int status = 0; if (check_create_dir (filename)) @@ -302,10 +304,17 @@ static int rrd_create_file (char *filename, const data_set_t *ds) return (-1); } + status = snprintf (step, sizeof (step), "%i", interval_g); + if ((status < 1) || (status >= sizeof (step))) + { + syslog (LOG_ERR, "rrdtool plugin: snprintf failed."); + return (-1); + } + argv[0] = "create"; argv[1] = filename; argv[2] = "-s"; - argv[3] = COLLECTD_STEP; + argv[3] = step; j = 4; for (i = 0; i < ds_num; i++) diff --git a/src/sensors.c b/src/sensors.c index 99b92568..b1454a6e 100644 --- a/src/sensors.c +++ b/src/sensors.c @@ -384,7 +384,7 @@ static void sensors_submit (const char *plugin_instance, vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "sensors"); strcpy (vl.plugin_instance, plugin_instance); strcpy (vl.type_instance, type_instance); diff --git a/src/serial.c b/src/serial.c index 6ca752c6..8f8e433b 100644 --- a/src/serial.c +++ b/src/serial.c @@ -55,7 +55,7 @@ static void serial_submit (const char *type_instance, vl.values = values; vl.values_len = 2; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "serial"); strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); diff --git a/src/swap.c b/src/swap.c index f03a5a9e..8e040443 100644 --- a/src/swap.c +++ b/src/swap.c @@ -133,7 +133,7 @@ static void swap_submit (const char *type_instance, double value) vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "swap"); strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); diff --git a/src/tape.c b/src/tape.c index e0b8b511..85a63a89 100644 --- a/src/tape.c +++ b/src/tape.c @@ -122,7 +122,7 @@ static void tape_submit (const char *plugin_instance, vl.values = values; vl.values_len = 2; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "tape"); strncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance)); diff --git a/src/traffic.c b/src/traffic.c index 5fc55d75..619208c8 100644 --- a/src/traffic.c +++ b/src/traffic.c @@ -232,7 +232,7 @@ static void if_submit (const char *dev, const char *type, vl.values = values; vl.values_len = 2; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "interface"); strncpy (vl.type_instance, dev, sizeof (vl.type_instance)); diff --git a/src/wireless.c b/src/wireless.c index 929d5d8a..10414531 100644 --- a/src/wireless.c +++ b/src/wireless.c @@ -84,7 +84,7 @@ static void wireless_submit (const char *plugin_instance, const char *type, vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "wireless"); strncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance)); -- 2.11.0