X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fvarnish.c;h=c6c4df05d413b97fe2ee1de80d81b3c42f29e2e1;hb=7bab45b57d6ef99ae55c499c51478dd63c3b1397;hp=8e6d95eefadb2c8cced71ceb87c22643457f648b;hpb=dd8429c16bc57f949abb2537e003b76ad88b6f90;p=collectd.git diff --git a/src/varnish.c b/src/varnish.c index 8e6d95ee..c6c4df05 100644 --- a/src/varnish.c +++ b/src/varnish.c @@ -29,19 +29,19 @@ #include "configfile.h" #if HAVE_VARNISH_V4 -#include -#include +#include +#include typedef struct VSC_C_main c_varnish_stats_t; #endif #if HAVE_VARNISH_V3 -#include -#include +#include +#include typedef struct VSC_C_main c_varnish_stats_t; #endif #if HAVE_VARNISH_V2 -#include +#include typedef struct varnish_stats c_varnish_stats_t; #endif @@ -608,6 +608,7 @@ static int varnish_read (user_data_t *ud) /* {{{ */ status = VSM_n_Arg (vd, conf->instance); if (status < 0) { + VSM_Delete (vd); ERROR ("varnish plugin: VSM_n_Arg (\"%s\") failed " "with status %i.", conf->instance, status); @@ -621,7 +622,8 @@ static int varnish_read (user_data_t *ud) /* {{{ */ if (VSM_Open (vd)) #endif { - ERROR ("varnish plugin: Unable to load statistics."); + VSM_Delete (vd); + ERROR ("varnish plugin: Unable to open connection."); return (-1); } @@ -631,9 +633,17 @@ static int varnish_read (user_data_t *ud) /* {{{ */ #else /* if HAVE_VARNISH_V4 */ stats = VSC_Main(vd, NULL); #endif + if (!stats) + { + VSM_Delete (vd); + ERROR ("varnish plugin: Unable to get statistics."); + + return (-1); + } + varnish_monitor (conf, stats); - VSM_Close (vd); + VSM_Delete (vd); return (0); } /* }}} */ @@ -739,7 +749,7 @@ static int varnish_init (void) /* {{{ */ plugin_register_complex_read (/* group = */ "varnish", /* name = */ "varnish/localhost", /* callback = */ varnish_read, - /* interval = */ NULL, + /* interval = */ 0, /* user data = */ &ud); return (0); @@ -901,7 +911,7 @@ static int varnish_config_instance (const oconfig_item_t *ci) /* {{{ */ plugin_register_complex_read (/* group = */ "varnish", /* name = */ callback_name, /* callback = */ varnish_read, - /* interval = */ NULL, + /* interval = */ 0, /* user data = */ &ud); have_instance = 1;