+#if HAVE_VARNISH_V3
+static int varnish_read (user_data_t *ud) /* {{{ */
+{
+ struct VSM_data *vd;
+ const c_varnish_stats_t *stats;
+
+ user_config_t *conf;
+
+ if ((ud == NULL) || (ud->data == NULL))
+ return (EINVAL);
+
+ conf = ud->data;
+
+ vd = VSM_New();
+ VSC_Setup(vd);
+
+ if (conf->instance != NULL)
+ {
+ int status;
+
+ status = VSM_n_Arg (vd, conf->instance);
+ if (status < 0)
+ {
+ ERROR ("varnish plugin: VSM_n_Arg (\"%s\") failed "
+ "with status %i.",
+ conf->instance, status);
+ return (-1);
+ }
+ }
+
+ if (VSC_Open (vd, /* diag = */ 1))
+ {
+ ERROR ("varnish plugin: Unable to load statistics.");
+
+ return (-1);
+ }
+
+ stats = VSC_Main(vd);
+
+ varnish_monitor (conf, stats);
+ VSM_Close (vd);
+
+ return (0);
+} /* }}} */
+#else /* if HAVE_VARNISH_V2 */