From: Marc Fournier Date: Tue, 15 Sep 2015 16:16:07 +0000 (+0200) Subject: plugin.c: add timer on plugins read functions X-Git-Tag: collectd-5.6.0~538^2~2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=8fd62e3a46cd43b632aa6a143bdb3ebf544170c0;p=collectd.git plugin.c: add timer on plugins read functions Print out the value in a debug message. Also emit a warning when it exceeds the configured Interval. --- diff --git a/src/daemon/plugin.c b/src/daemon/plugin.c index b57dd4a2..36c1b60d 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,6 +609,20 @@ 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.", rf->rf_name,