#include "configfile.h"
#if HAVE_VARNISH_V4
-#include <varnish/vapi/vsm.h>
-#include <varnish/vapi/vsc.h>
+#include <vapi/vsm.h>
+#include <vapi/vsc.h>
typedef struct VSC_C_main c_varnish_stats_t;
#endif
#if HAVE_VARNISH_V3
-#include <varnish/varnishapi.h>
-#include <varnish/vsc.h>
+#include <varnishapi.h>
+#include <vsc.h>
typedef struct VSC_C_main c_varnish_stats_t;
#endif
#if HAVE_VARNISH_V2
-#include <varnish/varnishapi.h>
+#include <varnishapi.h>
typedef struct varnish_stats c_varnish_stats_t;
#endif
{
struct VSM_data *vd;
const c_varnish_stats_t *stats;
+ _Bool ok;
user_config_t *conf;
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);
}
#if HAVE_VARNISH_V3
- if (VSC_Open (vd, /* diag = */ 1))
+ ok = (VSC_Open (vd, /* diag = */ 1) == 0);
#else /* if HAVE_VARNISH_V4 */
- if (VSM_Open (vd))
+ ok = (VSM_Open (vd) == 0);
#endif
+ if (!ok)
{
- ERROR ("varnish plugin: Unable to load statistics.");
+ VSM_Delete (vd);
+ ERROR ("varnish plugin: Unable to open connection.");
return (-1);
}
#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);
} /* }}} */
plugin_register_complex_read (/* group = */ "varnish",
/* name = */ "varnish/localhost",
/* callback = */ varnish_read,
- /* interval = */ NULL,
+ /* interval = */ 0,
/* user data = */ &ud);
return (0);
plugin_register_complex_read (/* group = */ "varnish",
/* name = */ callback_name,
/* callback = */ varnish_read,
- /* interval = */ NULL,
+ /* interval = */ 0,
/* user data = */ &ud);
have_instance = 1;