From: Marc Fournier Date: Wed, 2 Dec 2015 08:14:59 +0000 (+0100) Subject: Merge pull request #1293 from mfournier/read-threads-timing X-Git-Tag: collectd-5.6.0~538 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=ef07224d5a3e24ccbc71765194d91a8e00ce16fc;hp=cfb1c97ca06d84415409a8c9a9b1665e43520756;p=collectd.git Merge pull request #1293 from mfournier/read-threads-timing Read threads timing --- diff --git a/src/daemon/plugin.c b/src/daemon/plugin.c index fe6cc2b3..0919bdfe 100644 --- a/src/daemon/plugin.c +++ b/src/daemon/plugin.c @@ -483,7 +483,9 @@ static void *plugin_read_thread (void __attribute__((unused)) *args) { read_func_t *rf; plugin_ctx_t old_ctx; + cdtime_t start; cdtime_t now; + cdtime_t elapsed; int status; int rf_type; int rc; @@ -562,6 +564,8 @@ static void *plugin_read_thread (void __attribute__((unused)) *args) DEBUG ("plugin_read_thread: Handling `%s'.", rf->rf_name); + start = cdtime (); + old_ctx = plugin_set_ctx (rf->rf_ctx); if (rf_type == RF_SIMPLE) @@ -605,8 +609,22 @@ static void *plugin_read_thread (void __attribute__((unused)) *args) /* update the ``next read due'' field */ now = cdtime (); + /* calculate the time spent in the read function */ + elapsed = (now - start); + + if (elapsed > rf->rf_effective_interval) + WARNING ("plugin_read_thread: read-function of the `%s' plugin took %.3f " + "seconds, which is above its read interval (%.3f seconds). You might " + "want to adjust the `Interval' or `ReadThreads' settings.", + rf->rf_name, CDTIME_T_TO_DOUBLE(elapsed), + CDTIME_T_TO_DOUBLE(rf->rf_effective_interval)); + + DEBUG ("plugin_read_thread: read-function of the `%s' plugin took " + "%.6f seconds.", + rf->rf_name, CDTIME_T_TO_DOUBLE(elapsed)); + DEBUG ("plugin_read_thread: Effective interval of the " - "%s plugin is %.3f seconds.", + "`%s' plugin is %.3f seconds.", rf->rf_name, CDTIME_T_TO_DOUBLE (rf->rf_effective_interval)); @@ -623,7 +641,7 @@ static void *plugin_read_thread (void __attribute__((unused)) *args) rf->rf_next_read = now; } - DEBUG ("plugin_read_thread: Next read of the %s plugin at %.3f.", + DEBUG ("plugin_read_thread: Next read of the `%s' plugin at %.3f.", rf->rf_name, CDTIME_T_TO_DOUBLE (rf->rf_next_read)); diff --git a/src/snmp.c b/src/snmp.c index 162426a1..9f4714d3 100644 --- a/src/snmp.c +++ b/src/snmp.c @@ -1783,8 +1783,6 @@ static int csnmp_read_value (host_definition_t *host, data_definition_t *data) static int csnmp_read_host (user_data_t *ud) { host_definition_t *host; - cdtime_t time_start; - cdtime_t time_end; int status; int success; int i; @@ -1794,8 +1792,6 @@ static int csnmp_read_host (user_data_t *ud) if (host->interval == 0) host->interval = plugin_get_interval (); - time_start = cdtime (); - if (host->sess_handle == NULL) csnmp_host_open_session (host); @@ -1816,16 +1812,6 @@ static int csnmp_read_host (user_data_t *ud) success++; } - time_end = cdtime (); - if ((time_end - time_start) > host->interval) - { - WARNING ("snmp plugin: Host `%s' should be queried every %.3f " - "seconds, but reading all values takes %.3f seconds.", - host->name, - CDTIME_T_TO_DOUBLE (host->interval), - CDTIME_T_TO_DOUBLE (time_end - time_start)); - } - if (success == 0) return (-1);