]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Allow to configure monitored
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 20 Jul 2017 07:18:10 +0000 (08:18 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 20 Jul 2017 07:18:10 +0000 (08:18 +0100)
src/controller.c
src/libserver/cfg_file.h
src/libserver/cfg_rcl.c
src/libserver/monitored.c

index cef428eba8a70fe0508935aa8921fe85a61bc972..2f6fef71648afe6da1d21de9967fd37b73cde91c 100644 (file)
@@ -3792,7 +3792,10 @@ start_controller_worker (struct rspamd_worker *worker)
        rspamd_stat_init (worker->srv->cfg, ctx->ev_base);
 
        if (worker->index == 0) {
-               rspamd_worker_init_monitored (worker, ctx->ev_base, ctx->resolver);
+               if (!ctx->cfg->disable_monitored) {
+                       rspamd_worker_init_monitored (worker, ctx->ev_base, ctx->resolver);
+               }
+
                rspamd_map_watch (worker->srv->cfg, ctx->ev_base, ctx->resolver, TRUE);
        }
        else {
index 44b8dd85a0d6aa39c28eeff07af9ef9703fed94e..45202f5ab92e96937f28a3ba8f8863f1fa6ff0e2 100644 (file)
@@ -377,7 +377,10 @@ struct rspamd_config {
 
        GList *maps;                                    /**< maps active                                                                                */
        gdouble map_timeout;                            /**< maps watch timeout                                                                 */
-       gdouble map_file_watch_multiplier;              /**< multiplier for watch timeout when maps are files */
+       gdouble map_file_watch_multiplier;              /**< multiplier for watch timeout when maps are files */
+
+       gdouble monitored_interval;                     /**< interval between monitored checks                                  */
+       gboolean disable_monitored;                     /**< disable monitoring completely                                              */
 
        struct symbols_cache *cache;                    /**< symbols cache object                                                               */
        gchar *cache_filename;                          /**< filename of cache file                                                             */
index 67f91ab9b4e67f434f79086e58a1f9f635187aaa..596be1cf6782939ebc665df179cad0f1024d6dde 100644 (file)
@@ -1989,6 +1989,18 @@ rspamd_rcl_config_init (struct rspamd_config *cfg)
                        G_STRUCT_OFFSET (struct rspamd_config, map_file_watch_multiplier),
                        0,
                        "Multiplier for map watch interval when map is file");
+       rspamd_rcl_add_default_handler (sub,
+                       "monitoring_watch_interval",
+                       rspamd_rcl_parse_struct_time,
+                       G_STRUCT_OFFSET (struct rspamd_config, monitored_interval),
+                       RSPAMD_CL_FLAG_TIME_FLOAT,
+                       "Interval for checking monitored instances");
+       rspamd_rcl_add_default_handler (sub,
+                       "disable_monitoring",
+                       rspamd_rcl_parse_struct_boolean,
+                       G_STRUCT_OFFSET (struct rspamd_config, disable_monitored),
+                       0,
+                       "Disable monitoring completely");
        rspamd_rcl_add_default_handler (sub,
                        "dynamic_conf",
                        rspamd_rcl_parse_struct_string,
index 01979b11e15bb5cca2f64f684038f55e03d7e5a3..cc11183b2a4e55d2c836947a0debc4c9b5b77e22 100644 (file)
@@ -414,6 +414,10 @@ rspamd_monitored_ctx_config (struct rspamd_monitored_ctx *ctx,
        ctx->change_cb = change_cb;
        ctx->ud = ud;
 
+       if (cfg->monitored_interval != 0) {
+               ctx->monitoring_interval = cfg->monitored_interval;
+       }
+
        /* Start all events */
        for (i = 0; i < ctx->elts->len; i ++) {
                m = g_ptr_array_index (ctx->elts, i);