|
|
b784eaa |
diff --git a/configure.ac b/configure.ac
|
|
|
b784eaa |
index 9dd30c7..bee86bf 100644
|
|
|
b784eaa |
--- a/configure.ac
|
|
|
b784eaa |
+++ b/configure.ac
|
|
|
b784eaa |
@@ -4590,25 +4590,18 @@ fi
|
|
|
b784eaa |
if test "x$with_libvarnish" = "xyes"
|
|
|
b784eaa |
then
|
|
|
b784eaa |
SAVE_CPPFLAGS="$CPPFLAGS"
|
|
|
b784eaa |
- CPPFLAGS="$CPPFLAGS $with_libvarnish_cflags"
|
|
|
b784eaa |
- AC_CHECK_HEADERS(varnish/varnishapi.h, [], [with_libvarnish="no (varnish/varnishapi.h not found)"])
|
|
|
b784eaa |
-
|
|
|
b784eaa |
- CPPFLAGS="$SAVE_CPPFLAGS"
|
|
|
b784eaa |
-fi
|
|
|
b784eaa |
-if test "x$with_libvarnish" = "xyes"
|
|
|
b784eaa |
-then
|
|
|
b784eaa |
- SAVE_CPPFLAGS="$CPPFLAGS"
|
|
|
b784eaa |
- #SAVE_LDFLAGS="$LDFLAGS"
|
|
|
b784eaa |
|
|
|
b784eaa |
CPPFLAGS="$CPPFLAGS $with_libvarnish_cflags"
|
|
|
b784eaa |
- #LDFLAGS="$LDFLAGS $with_libvarnish_libs"
|
|
|
b784eaa |
|
|
|
b784eaa |
- AC_CHECK_HEADERS(varnish/vsc.h,
|
|
|
b784eaa |
- [AC_DEFINE([HAVE_VARNISH_V3], [1], [Varnish 3 API support])],
|
|
|
b784eaa |
- [AC_DEFINE([HAVE_VARNISH_V2], [1], [Varnish 2 API support])])
|
|
|
b784eaa |
+ AC_CHECK_HEADERS(varnish/vapi/vsc.h,
|
|
|
b784eaa |
+ [AC_DEFINE([HAVE_VARNISH_V4], [1], [Varnish 4 API support])],
|
|
|
b784eaa |
+ [AC_CHECK_HEADERS(varnish/vsc.h,
|
|
|
b784eaa |
+ [AC_DEFINE([HAVE_VARNISH_V3], [1], [Varnish 3 API support])],
|
|
|
b784eaa |
+ [AC_CHECK_HEADERS(varnish/varnishapi.h,
|
|
|
b784eaa |
+ [AC_DEFINE([HAVE_VARNISH_V2], [1], [Varnish 2 API support])],
|
|
|
b784eaa |
+ [with_libvarnish="no (found none of the varnish header files)"])])])
|
|
|
b784eaa |
|
|
|
b784eaa |
CPPFLAGS="$SAVE_CPPFLAGS"
|
|
|
b784eaa |
- #LDFLAGS="$SAVE_LDFLAGS"
|
|
|
b784eaa |
fi
|
|
|
b784eaa |
if test "x$with_libvarnish" = "xyes"
|
|
|
b784eaa |
then
|
|
|
b784eaa |
diff --git a/src/collectd.conf.in b/src/collectd.conf.in
|
|
|
b784eaa |
index 80e1d5c..19b3854 100644
|
|
|
b784eaa |
--- a/src/collectd.conf.in
|
|
|
b784eaa |
+++ b/src/collectd.conf.in
|
|
|
b784eaa |
@@ -1159,25 +1159,26 @@
|
|
|
b784eaa |
# If you prefer defining another instance you can do
|
|
|
b784eaa |
# so by using <Instance "myinstance">
|
|
|
b784eaa |
# <Instance>
|
|
|
b784eaa |
-# CollectCache true
|
|
|
b784eaa |
# CollectBackend true
|
|
|
b784eaa |
-# CollectBan false # Varnish 3 only
|
|
|
b784eaa |
+# CollectBan false # Varnish 3 and above
|
|
|
b784eaa |
+# CollectCache true
|
|
|
b784eaa |
# CollectConnections true
|
|
|
b784eaa |
# CollectDirectorDNS false # Varnish 3 only
|
|
|
b784eaa |
-# CollectSHM true
|
|
|
b784eaa |
# CollectESI false
|
|
|
b784eaa |
# CollectFetch false
|
|
|
b784eaa |
# CollectHCB false
|
|
|
b784eaa |
# CollectObjects false
|
|
|
b784eaa |
# CollectPurge false # Varnish 2 only
|
|
|
b784eaa |
# CollectSession false
|
|
|
b784eaa |
+# CollectSHM true
|
|
|
b784eaa |
# CollectSMA false # Varnish 2 only
|
|
|
b784eaa |
# CollectSMS false
|
|
|
b784eaa |
# CollectSM false # Varnish 2 only
|
|
|
b784eaa |
# CollectStruct false
|
|
|
b784eaa |
# CollectTotals false
|
|
|
b784eaa |
-# CollectUptime false
|
|
|
b784eaa |
+# CollectUptime false # Varnish 3 and above
|
|
|
b784eaa |
# CollectVCL false
|
|
|
b784eaa |
+# CollectVSM false # Varnish 4 only
|
|
|
b784eaa |
# CollectWorkers false
|
|
|
b784eaa |
# </Instance>
|
|
|
b784eaa |
#</Plugin>
|
|
|
b784eaa |
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
|
|
|
b784eaa |
index ac0ff2a..60cc9b5 100644
|
|
|
b784eaa |
--- a/src/collectd.conf.pod
|
|
|
b784eaa |
+++ b/src/collectd.conf.pod
|
|
|
b784eaa |
@@ -6305,22 +6305,35 @@ Take the UUID from the given file (default I</etc/uuid>).
|
|
|
b784eaa |
=head2 Plugin C<varnish>
|
|
|
b784eaa |
|
|
|
b784eaa |
The I<varnish plugin> collects information about Varnish, an HTTP accelerator.
|
|
|
b784eaa |
+It collects a subset of the values displayed by L<varnishstat(1)>, and
|
|
|
b784eaa |
+organizes them in categories which can be enabled or disabled. Currently only
|
|
|
b784eaa |
+metrics shown in L<varnishstat(1)>'s I<MAIN> section are collected. The exact
|
|
|
b784eaa |
+meaning of each metric can be found in L<varnish-counters(7)>.
|
|
|
b784eaa |
|
|
|
b784eaa |
Synopsis:
|
|
|
b784eaa |
|
|
|
b784eaa |
<Plugin "varnish">
|
|
|
b784eaa |
<Instance "example">
|
|
|
b784eaa |
+ CollectBackend true
|
|
|
b784eaa |
+ CollectBan false
|
|
|
b784eaa |
CollectCache true
|
|
|
b784eaa |
CollectConnections true
|
|
|
b784eaa |
- CollectBackend true
|
|
|
b784eaa |
- CollectSHM true
|
|
|
b784eaa |
+ CollectDirectorDNS false
|
|
|
b784eaa |
CollectESI false
|
|
|
b784eaa |
CollectFetch false
|
|
|
b784eaa |
CollectHCB false
|
|
|
b784eaa |
+ CollectObjects false
|
|
|
b784eaa |
+ CollectPurge false
|
|
|
b784eaa |
+ CollectSession false
|
|
|
b784eaa |
+ CollectSHM true
|
|
|
b784eaa |
CollectSMA false
|
|
|
b784eaa |
CollectSMS false
|
|
|
b784eaa |
CollectSM false
|
|
|
b784eaa |
+ CollectStruct false
|
|
|
b784eaa |
CollectTotals false
|
|
|
b784eaa |
+ CollectUptime false
|
|
|
b784eaa |
+ CollectVCL false
|
|
|
b784eaa |
+ CollectVSM false
|
|
|
b784eaa |
CollectWorkers false
|
|
|
b784eaa |
</Instance>
|
|
|
b784eaa |
</Plugin>
|
|
|
b784eaa |
@@ -6334,29 +6347,24 @@ Inside each E<lt>B<Instance>E<gt> blocks, the following options are recognized:
|
|
|
b784eaa |
|
|
|
b784eaa |
=over 4
|
|
|
b784eaa |
|
|
|
b784eaa |
-=item B<CollectCache> B<true>|B<false>
|
|
|
b784eaa |
-
|
|
|
b784eaa |
-Cache hits and misses. True by default.
|
|
|
b784eaa |
-
|
|
|
b784eaa |
-=item B<CollectConnections> B<true>|B<false>
|
|
|
b784eaa |
-
|
|
|
b784eaa |
-Number of client connections received, accepted and dropped. True by default.
|
|
|
b784eaa |
-
|
|
|
b784eaa |
=item B<CollectBackend> B<true>|B<false>
|
|
|
b784eaa |
|
|
|
b784eaa |
Back-end connection statistics, such as successful, reused,
|
|
|
b784eaa |
and closed connections. True by default.
|
|
|
b784eaa |
|
|
|
b784eaa |
-=item B<CollectSHM> B<true>|B<false>
|
|
|
b784eaa |
-
|
|
|
b784eaa |
-Statistics about the shared memory log, a memory region to store
|
|
|
b784eaa |
-log messages which is flushed to disk when full. True by default.
|
|
|
b784eaa |
-
|
|
|
b784eaa |
=item B<CollectBan> B<true>|B<false>
|
|
|
b784eaa |
|
|
|
b784eaa |
Statistics about ban operations, such as number of bans added, retired, and
|
|
|
b784eaa |
number of objects tested against ban operations. Only available with Varnish
|
|
|
b784eaa |
-3.x. False by default.
|
|
|
b784eaa |
+3.x and above. False by default.
|
|
|
b784eaa |
+
|
|
|
b784eaa |
+=item B<CollectCache> B<true>|B<false>
|
|
|
b784eaa |
+
|
|
|
b784eaa |
+Cache hits and misses. True by default.
|
|
|
b784eaa |
+
|
|
|
b784eaa |
+=item B<CollectConnections> B<true>|B<false>
|
|
|
b784eaa |
+
|
|
|
b784eaa |
+Number of client connections received, accepted and dropped. True by default.
|
|
|
b784eaa |
|
|
|
b784eaa |
=item B<CollectDirectorDNS> B<true>|B<false>
|
|
|
b784eaa |
|
|
|
b784eaa |
@@ -6390,7 +6398,14 @@ number of objects tested against purge operations. Only available with Varnish
|
|
|
b784eaa |
=item B<CollectSession> B<true>|B<false>
|
|
|
b784eaa |
|
|
|
b784eaa |
Client session statistics. Number of past and current sessions, session herd and
|
|
|
b784eaa |
-linger counters, etc. False by default.
|
|
|
b784eaa |
+linger counters, etc. False by default. Note that if using Varnish 4.x, some
|
|
|
b784eaa |
+metrics found in the Connections and Threads sections with previous versions of
|
|
|
b784eaa |
+Varnish have been moved here.
|
|
|
b784eaa |
+
|
|
|
b784eaa |
+=item B<CollectSHM> B<true>|B<false>
|
|
|
b784eaa |
+
|
|
|
b784eaa |
+Statistics about the shared memory log, a memory region to store
|
|
|
b784eaa |
+log messages which is flushed to disk when full. True by default.
|
|
|
b784eaa |
|
|
|
b784eaa |
=item B<CollectSMA> B<true>|B<false>
|
|
|
b784eaa |
|
|
|
b784eaa |
@@ -6421,12 +6436,17 @@ the number of requests and bytes transferred. False by default.
|
|
|
b784eaa |
|
|
|
b784eaa |
=item B<CollectUptime> B<true>|B<false>
|
|
|
b784eaa |
|
|
|
b784eaa |
-Varnish uptime. False by default.
|
|
|
b784eaa |
+Varnish uptime. Only available with Varnish 3.x and above. False by default.
|
|
|
b784eaa |
|
|
|
b784eaa |
=item B<CollectVCL> B<true>|B<false>
|
|
|
b784eaa |
|
|
|
b784eaa |
Number of total (available + discarded) VCL (config files). False by default.
|
|
|
b784eaa |
|
|
|
b784eaa |
+=item B<CollectVSM> B<true>|B<false>
|
|
|
b784eaa |
+
|
|
|
b784eaa |
+Collect statistics about Varnish's shared memory usage (used by the logging and
|
|
|
b784eaa |
+statistics subsystems). Only available with Varnish 4.x. False by default.
|
|
|
b784eaa |
+
|
|
|
b784eaa |
=item B<CollectWorkers> B<true>|B<false>
|
|
|
b784eaa |
|
|
|
b784eaa |
Collect statistics about worker threads. False by default.
|
|
|
b784eaa |
diff --git a/src/varnish.c b/src/varnish.c
|
|
|
b784eaa |
index 3a8dddd..8e6d95e 100644
|
|
|
b784eaa |
--- a/src/varnish.c
|
|
|
b784eaa |
+++ b/src/varnish.c
|
|
|
b784eaa |
@@ -28,14 +28,20 @@
|
|
|
b784eaa |
#include "plugin.h"
|
|
|
b784eaa |
#include "configfile.h"
|
|
|
b784eaa |
|
|
|
b784eaa |
-#include <varnish/varnishapi.h>
|
|
|
b784eaa |
+#if HAVE_VARNISH_V4
|
|
|
b784eaa |
+#include <varnish/vapi/vsm.h>
|
|
|
b784eaa |
+#include <varnish/vapi/vsc.h>
|
|
|
b784eaa |
+typedef struct VSC_C_main c_varnish_stats_t;
|
|
|
b784eaa |
+#endif
|
|
|
b784eaa |
|
|
|
b784eaa |
#if HAVE_VARNISH_V3
|
|
|
b784eaa |
-# include <varnish/vsc.h>
|
|
|
b784eaa |
+#include <varnish/varnishapi.h>
|
|
|
b784eaa |
+#include <varnish/vsc.h>
|
|
|
b784eaa |
typedef struct VSC_C_main c_varnish_stats_t;
|
|
|
b784eaa |
#endif
|
|
|
b784eaa |
|
|
|
b784eaa |
#if HAVE_VARNISH_V2
|
|
|
b784eaa |
+#include <varnish/varnishapi.h>
|
|
|
b784eaa |
typedef struct varnish_stats c_varnish_stats_t;
|
|
|
b784eaa |
#endif
|
|
|
b784eaa |
|
|
|
b784eaa |
@@ -67,11 +73,14 @@ struct user_config_s {
|
|
|
b784eaa |
#endif
|
|
|
b784eaa |
_Bool collect_struct;
|
|
|
b784eaa |
_Bool collect_totals;
|
|
|
b784eaa |
-#ifdef HAVE_VARNISH_V3
|
|
|
b784eaa |
+#if HAVE_VARNISH_V3 || HAVE_VARNISH_V4
|
|
|
b784eaa |
_Bool collect_uptime;
|
|
|
b784eaa |
#endif
|
|
|
b784eaa |
_Bool collect_vcl;
|
|
|
b784eaa |
_Bool collect_workers;
|
|
|
b784eaa |
+#if HAVE_VARNISH_V4
|
|
|
b784eaa |
+ _Bool collect_vsm;
|
|
|
b784eaa |
+#endif
|
|
|
b784eaa |
};
|
|
|
b784eaa |
typedef struct user_config_s user_config_t; /* }}} */
|
|
|
b784eaa |
|
|
|
b784eaa |
@@ -141,10 +150,12 @@ static void varnish_monitor (const user_config_t *conf, /* {{{ */
|
|
|
b784eaa |
|
|
|
b784eaa |
if (conf->collect_connections)
|
|
|
b784eaa |
{
|
|
|
b784eaa |
+#ifndef HAVE_VARNISH_V4
|
|
|
b784eaa |
/* Client connections accepted */
|
|
|
b784eaa |
varnish_submit_derive (conf->instance, "connections", "connections", "accepted", stats->client_conn);
|
|
|
b784eaa |
/* Connection dropped, no sess */
|
|
|
b784eaa |
varnish_submit_derive (conf->instance, "connections", "connections", "dropped" , stats->client_drop);
|
|
|
b784eaa |
+#endif
|
|
|
b784eaa |
/* Client requests received */
|
|
|
b784eaa |
varnish_submit_derive (conf->instance, "connections", "connections", "received", stats->client_req);
|
|
|
b784eaa |
}
|
|
|
b784eaa |
@@ -225,7 +236,7 @@ static void varnish_monitor (const user_config_t *conf, /* {{{ */
|
|
|
b784eaa |
varnish_submit_derive (conf->instance, "fetch", "http_requests", "zero" , stats->fetch_zero);
|
|
|
b784eaa |
/* Fetch failed */
|
|
|
b784eaa |
varnish_submit_derive (conf->instance, "fetch", "http_requests", "failed" , stats->fetch_failed);
|
|
|
b784eaa |
-#if HAVE_VARNISH_V3
|
|
|
b784eaa |
+#if HAVE_VARNISH_V3 || HAVE_VARNISH_V4
|
|
|
b784eaa |
/* Fetch no body (1xx) */
|
|
|
b784eaa |
varnish_submit_derive (conf->instance, "fetch", "http_requests", "no_body_1xx", stats->fetch_1xx);
|
|
|
b784eaa |
/* Fetch no body (204) */
|
|
|
b784eaa |
@@ -263,12 +274,17 @@ static void varnish_monitor (const user_config_t *conf, /* {{{ */
|
|
|
b784eaa |
#endif
|
|
|
b784eaa |
/* HTTP header overflows */
|
|
|
b784eaa |
varnish_submit_derive (conf->instance, "objects", "total_objects", "header_overflow", stats->losthdr);
|
|
|
b784eaa |
+#if HAVE_VARNISH_V4
|
|
|
b784eaa |
+ /* N purged objects */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "objects", "total_objects", "purged", stats->n_obj_purged);
|
|
|
b784eaa |
+#else
|
|
|
b784eaa |
/* Objects sent with sendfile */
|
|
|
b784eaa |
varnish_submit_derive (conf->instance, "objects", "total_objects", "sent_sendfile", stats->n_objsendfile);
|
|
|
b784eaa |
/* Objects sent with write */
|
|
|
b784eaa |
varnish_submit_derive (conf->instance, "objects", "total_objects", "sent_write", stats->n_objwrite);
|
|
|
b784eaa |
/* Objects overflowing workspace */
|
|
|
b784eaa |
varnish_submit_derive (conf->instance, "objects", "total_objects", "workspace_overflow", stats->n_objoverflow);
|
|
|
b784eaa |
+#endif
|
|
|
b784eaa |
}
|
|
|
b784eaa |
|
|
|
b784eaa |
#if HAVE_VARNISH_V2
|
|
|
b784eaa |
@@ -287,7 +303,8 @@ static void varnish_monitor (const user_config_t *conf, /* {{{ */
|
|
|
b784eaa |
/* N duplicate purges removed */
|
|
|
b784eaa |
varnish_submit_derive (conf->instance, "purge", "total_operations", "duplicate", stats->n_purge_dups);
|
|
|
b784eaa |
}
|
|
|
b784eaa |
-#else
|
|
|
b784eaa |
+#endif
|
|
|
b784eaa |
+#if HAVE_VARNISH_V3
|
|
|
b784eaa |
if (conf->collect_ban)
|
|
|
b784eaa |
{
|
|
|
b784eaa |
/* N total active bans */
|
|
|
b784eaa |
@@ -304,6 +321,27 @@ static void varnish_monitor (const user_config_t *conf, /* {{{ */
|
|
|
b784eaa |
varnish_submit_derive (conf->instance, "ban", "total_operations", "duplicate", stats->n_ban_dups);
|
|
|
b784eaa |
}
|
|
|
b784eaa |
#endif
|
|
|
b784eaa |
+#if HAVE_VARNISH_V4
|
|
|
b784eaa |
+ if (conf->collect_ban)
|
|
|
b784eaa |
+ {
|
|
|
b784eaa |
+ /* N total active bans */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "ban", "total_operations", "total", stats->bans);
|
|
|
b784eaa |
+ /* N new bans added */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "ban", "total_operations", "added", stats->bans_added);
|
|
|
b784eaa |
+ /* N bans using obj */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "ban", "total_operations", "obj", stats->bans_obj);
|
|
|
b784eaa |
+ /* N bans using req */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "ban", "total_operations", "req", stats->bans_req);
|
|
|
b784eaa |
+ /* N new bans completed */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "ban", "total_operations", "completed", stats->bans_completed);
|
|
|
b784eaa |
+ /* N old bans deleted */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "ban", "total_operations", "deleted", stats->bans_deleted);
|
|
|
b784eaa |
+ /* N objects tested */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "ban", "total_operations", "tested", stats->bans_tested);
|
|
|
b784eaa |
+ /* N duplicate bans removed */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "ban", "total_operations", "duplicate", stats->bans_dups);
|
|
|
b784eaa |
+ }
|
|
|
b784eaa |
+#endif
|
|
|
b784eaa |
|
|
|
b784eaa |
if (conf->collect_session)
|
|
|
b784eaa |
{
|
|
|
b784eaa |
@@ -313,8 +351,21 @@ static void varnish_monitor (const user_config_t *conf, /* {{{ */
|
|
|
b784eaa |
varnish_submit_derive (conf->instance, "session", "total_operations", "pipeline", stats->sess_pipeline);
|
|
|
b784eaa |
/* Session Read Ahead */
|
|
|
b784eaa |
varnish_submit_derive (conf->instance, "session", "total_operations", "readahead", stats->sess_readahead);
|
|
|
b784eaa |
+#if HAVE_VARNISH_V4
|
|
|
b784eaa |
+ /* Sessions accepted */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "session", "total_operations", "accepted", stats->sess_conn);
|
|
|
b784eaa |
+ /* Sessions dropped for thread */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "session", "total_operations", "dropped", stats->sess_drop);
|
|
|
b784eaa |
+ /* Sessions accept failure */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "session", "total_operations", "failed", stats->sess_fail);
|
|
|
b784eaa |
+ /* Sessions pipe overflow */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "session", "total_operations", "overflow", stats->sess_pipe_overflow);
|
|
|
b784eaa |
+ /* Sessions queued for thread */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "session", "total_operations", "queued", stats->sess_queued);
|
|
|
b784eaa |
+#else
|
|
|
b784eaa |
/* Session Linger */
|
|
|
b784eaa |
varnish_submit_derive (conf->instance, "session", "total_operations", "linger", stats->sess_linger);
|
|
|
b784eaa |
+#endif
|
|
|
b784eaa |
/* Session herd */
|
|
|
b784eaa |
varnish_submit_derive (conf->instance, "session", "total_operations", "herd", stats->sess_herd);
|
|
|
b784eaa |
}
|
|
|
b784eaa |
@@ -377,17 +428,21 @@ static void varnish_monitor (const user_config_t *conf, /* {{{ */
|
|
|
b784eaa |
|
|
|
b784eaa |
if (conf->collect_struct)
|
|
|
b784eaa |
{
|
|
|
b784eaa |
+#if !HAVE_VARNISH_V4
|
|
|
b784eaa |
/* N struct sess_mem */
|
|
|
b784eaa |
varnish_submit_gauge (conf->instance, "struct", "current_sessions", "sess_mem", stats->n_sess_mem);
|
|
|
b784eaa |
/* N struct sess */
|
|
|
b784eaa |
varnish_submit_gauge (conf->instance, "struct", "current_sessions", "sess", stats->n_sess);
|
|
|
b784eaa |
+#endif
|
|
|
b784eaa |
/* N struct object */
|
|
|
b784eaa |
varnish_submit_gauge (conf->instance, "struct", "objects", "object", stats->n_object);
|
|
|
b784eaa |
-#ifdef HAVE_VARNISH_V3
|
|
|
b784eaa |
+#if HAVE_VARNISH_V3 || HAVE_VARNISH_V4
|
|
|
b784eaa |
/* N unresurrected objects */
|
|
|
b784eaa |
varnish_submit_gauge (conf->instance, "struct", "objects", "vampireobject", stats->n_vampireobject);
|
|
|
b784eaa |
/* N struct objectcore */
|
|
|
b784eaa |
varnish_submit_gauge (conf->instance, "struct", "objects", "objectcore", stats->n_objectcore);
|
|
|
b784eaa |
+ /* N struct waitinglist */
|
|
|
b784eaa |
+ varnish_submit_gauge (conf->instance, "struct", "objects", "waitinglist", stats->n_waitinglist);
|
|
|
b784eaa |
#endif
|
|
|
b784eaa |
/* N struct objecthead */
|
|
|
b784eaa |
varnish_submit_gauge (conf->instance, "struct", "objects", "objecthead", stats->n_objecthead);
|
|
|
b784eaa |
@@ -415,13 +470,40 @@ static void varnish_monitor (const user_config_t *conf, /* {{{ */
|
|
|
b784eaa |
varnish_submit_derive (conf->instance, "totals", "total_operations", "pass", stats->s_pass);
|
|
|
b784eaa |
/* Total fetch */
|
|
|
b784eaa |
varnish_submit_derive (conf->instance, "totals", "total_operations", "fetches", stats->s_fetch);
|
|
|
b784eaa |
+#if HAVE_VARNISH_V4
|
|
|
b784eaa |
+ /* Total synth */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "totals", "total_bytes", "synth", stats->s_synth);
|
|
|
b784eaa |
+ /* Request header bytes */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "totals", "total_bytes", "req_header", stats->s_req_hdrbytes);
|
|
|
b784eaa |
+ /* Request body byte */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "totals", "total_bytes", "req_body", stats->s_req_bodybytes);
|
|
|
b784eaa |
+ /* Response header bytes */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "totals", "total_bytes", "resp_header", stats->s_resp_hdrbytes);
|
|
|
b784eaa |
+ /* Response body byte */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "totals", "total_bytes", "resp_body", stats->s_resp_bodybytes);
|
|
|
b784eaa |
+ /* Pipe request header bytes */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "totals", "total_bytes", "pipe_header", stats->s_pipe_hdrbytes);
|
|
|
b784eaa |
+ /* Piped bytes from client */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "totals", "total_bytes", "pipe_in", stats->s_pipe_in);
|
|
|
b784eaa |
+ /* Piped bytes to client */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "totals", "total_bytes", "pipe_out", stats->s_pipe_out);
|
|
|
b784eaa |
+ /* Number of purge operations */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "totals", "total_operations", "purges", stats->n_purges);
|
|
|
b784eaa |
+#else
|
|
|
b784eaa |
/* Total header bytes */
|
|
|
b784eaa |
varnish_submit_derive (conf->instance, "totals", "total_bytes", "header-bytes", stats->s_hdrbytes);
|
|
|
b784eaa |
/* Total body byte */
|
|
|
b784eaa |
varnish_submit_derive (conf->instance, "totals", "total_bytes", "body-bytes", stats->s_bodybytes);
|
|
|
b784eaa |
+#endif
|
|
|
b784eaa |
+#if HAVE_VARNISH_V3 || HAVE_VARNISH_V4
|
|
|
b784eaa |
+ /* Gzip operations */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "totals", "total_operations", "gzip", stats->n_gzip);
|
|
|
b784eaa |
+ /* Gunzip operations */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "totals", "total_operations", "gunzip", stats->n_gunzip);
|
|
|
b784eaa |
+#endif
|
|
|
b784eaa |
}
|
|
|
b784eaa |
|
|
|
b784eaa |
-#ifdef HAVE_VARNISH_V3
|
|
|
b784eaa |
+#if HAVE_VARNISH_V3 || HAVE_VARNISH_V4
|
|
|
b784eaa |
if (conf->collect_uptime)
|
|
|
b784eaa |
{
|
|
|
b784eaa |
/* Client uptime */
|
|
|
b784eaa |
@@ -437,10 +519,28 @@ static void varnish_monitor (const user_config_t *conf, /* {{{ */
|
|
|
b784eaa |
varnish_submit_gauge (conf->instance, "vcl", "vcl", "avail_vcl", stats->n_vcl_avail);
|
|
|
b784eaa |
/* N vcl discarded */
|
|
|
b784eaa |
varnish_submit_gauge (conf->instance, "vcl", "vcl", "discarded_vcl", stats->n_vcl_discard);
|
|
|
b784eaa |
+#if HAVE_VARNISH_V3 || HAVE_VARNISH_V4
|
|
|
b784eaa |
+ /* Loaded VMODs */
|
|
|
b784eaa |
+ varnish_submit_gauge (conf->instance, "vcl", "objects", "vmod", stats->vmods);
|
|
|
b784eaa |
+#endif
|
|
|
b784eaa |
}
|
|
|
b784eaa |
|
|
|
b784eaa |
if (conf->collect_workers)
|
|
|
b784eaa |
{
|
|
|
b784eaa |
+#ifdef HAVE_VARNISH_V4
|
|
|
b784eaa |
+ /* total number of threads */
|
|
|
b784eaa |
+ varnish_submit_gauge (conf->instance, "workers", "threads", "worker", stats->threads);
|
|
|
b784eaa |
+ /* threads created */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "workers", "total_threads", "created", stats->threads_created);
|
|
|
b784eaa |
+ /* thread creation failed */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "workers", "total_threads", "failed", stats->threads_failed);
|
|
|
b784eaa |
+ /* threads hit max */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "workers", "total_threads", "limited", stats->threads_limited);
|
|
|
b784eaa |
+ /* threads destroyed */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "workers", "total_threads", "dropped", stats->threads_destroyed);
|
|
|
b784eaa |
+ /* length of session queue */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "workers", "queue_length", "threads", stats->thread_queue_len);
|
|
|
b784eaa |
+#else
|
|
|
b784eaa |
/* worker threads */
|
|
|
b784eaa |
varnish_submit_gauge (conf->instance, "workers", "threads", "worker", stats->n_wrk);
|
|
|
b784eaa |
/* worker threads created */
|
|
|
b784eaa |
@@ -450,22 +550,40 @@ static void varnish_monitor (const user_config_t *conf, /* {{{ */
|
|
|
b784eaa |
/* worker threads limited */
|
|
|
b784eaa |
varnish_submit_derive (conf->instance, "workers", "total_threads", "limited", stats->n_wrk_max);
|
|
|
b784eaa |
/* dropped work requests */
|
|
|
b784eaa |
- varnish_submit_derive (conf->instance, "workers", "total_requests", "dropped", stats->n_wrk_drop);
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "workers", "total_threads", "dropped", stats->n_wrk_drop);
|
|
|
b784eaa |
#ifdef HAVE_VARNISH_V2
|
|
|
b784eaa |
/* queued work requests */
|
|
|
b784eaa |
varnish_submit_derive (conf->instance, "workers", "total_requests", "queued", stats->n_wrk_queue);
|
|
|
b784eaa |
/* overflowed work requests */
|
|
|
b784eaa |
varnish_submit_derive (conf->instance, "workers", "total_requests", "overflowed", stats->n_wrk_overflow);
|
|
|
b784eaa |
-#else
|
|
|
b784eaa |
+#else /* HAVE_VARNISH_V3 */
|
|
|
b784eaa |
/* queued work requests */
|
|
|
b784eaa |
varnish_submit_derive (conf->instance, "workers", "total_requests", "queued", stats->n_wrk_queued);
|
|
|
b784eaa |
/* work request queue length */
|
|
|
b784eaa |
varnish_submit_derive (conf->instance, "workers", "total_requests", "queue_length", stats->n_wrk_lqueue);
|
|
|
b784eaa |
#endif
|
|
|
b784eaa |
+#endif
|
|
|
b784eaa |
+ }
|
|
|
b784eaa |
+
|
|
|
b784eaa |
+#if HAVE_VARNISH_V4
|
|
|
b784eaa |
+ if (conf->collect_vsm)
|
|
|
b784eaa |
+ {
|
|
|
b784eaa |
+ /* Free VSM space */
|
|
|
b784eaa |
+ varnish_submit_gauge (conf->instance, "vsm", "bytes", "free", stats->vsm_free);
|
|
|
b784eaa |
+ /* Used VSM space */
|
|
|
b784eaa |
+ varnish_submit_gauge (conf->instance, "vsm", "bytes", "used", stats->vsm_used);
|
|
|
b784eaa |
+ /* Cooling VSM space */
|
|
|
b784eaa |
+ varnish_submit_gauge (conf->instance, "vsm", "bytes", "cooling", stats->vsm_cooling);
|
|
|
b784eaa |
+ /* Overflow VSM space */
|
|
|
b784eaa |
+ varnish_submit_gauge (conf->instance, "vsm", "bytes", "overflow", stats->vsm_overflow);
|
|
|
b784eaa |
+ /* Total overflowed VSM space */
|
|
|
b784eaa |
+ varnish_submit_derive (conf->instance, "vsm", "total_bytes", "overflowed", stats->vsm_overflowed);
|
|
|
b784eaa |
}
|
|
|
b784eaa |
+#endif
|
|
|
b784eaa |
+
|
|
|
b784eaa |
} /* }}} void varnish_monitor */
|
|
|
b784eaa |
|
|
|
b784eaa |
-#if HAVE_VARNISH_V3
|
|
|
b784eaa |
+#if HAVE_VARNISH_V3 || HAVE_VARNISH_V4
|
|
|
b784eaa |
static int varnish_read (user_data_t *ud) /* {{{ */
|
|
|
b784eaa |
{
|
|
|
b784eaa |
struct VSM_data *vd;
|
|
|
b784eaa |
@@ -479,7 +597,9 @@ static int varnish_read (user_data_t *ud) /* {{{ */
|
|
|
b784eaa |
conf = ud->data;
|
|
|
b784eaa |
|
|
|
b784eaa |
vd = VSM_New();
|
|
|
b784eaa |
+#if HAVE_VARNISH_V3
|
|
|
b784eaa |
VSC_Setup(vd);
|
|
|
b784eaa |
+#endif
|
|
|
b784eaa |
|
|
|
b784eaa |
if (conf->instance != NULL)
|
|
|
b784eaa |
{
|
|
|
b784eaa |
@@ -495,14 +615,22 @@ static int varnish_read (user_data_t *ud) /* {{{ */
|
|
|
b784eaa |
}
|
|
|
b784eaa |
}
|
|
|
b784eaa |
|
|
|
b784eaa |
+#if HAVE_VARNISH_V3
|
|
|
b784eaa |
if (VSC_Open (vd, /* diag = */ 1))
|
|
|
b784eaa |
+#else /* if HAVE_VARNISH_V4 */
|
|
|
b784eaa |
+ if (VSM_Open (vd))
|
|
|
b784eaa |
+#endif
|
|
|
b784eaa |
{
|
|
|
b784eaa |
ERROR ("varnish plugin: Unable to load statistics.");
|
|
|
b784eaa |
|
|
|
b784eaa |
return (-1);
|
|
|
b784eaa |
}
|
|
|
b784eaa |
|
|
|
b784eaa |
+#if HAVE_VARNISH_V3
|
|
|
b784eaa |
stats = VSC_Main(vd);
|
|
|
b784eaa |
+#else /* if HAVE_VARNISH_V4 */
|
|
|
b784eaa |
+ stats = VSC_Main(vd, NULL);
|
|
|
b784eaa |
+#endif
|
|
|
b784eaa |
|
|
|
b784eaa |
varnish_monitor (conf, stats);
|
|
|
b784eaa |
VSM_Close (vd);
|
|
|
b784eaa |
@@ -575,11 +703,14 @@ static int varnish_config_apply_default (user_config_t *conf) /* {{{ */
|
|
|
b784eaa |
conf->collect_sms = 0;
|
|
|
b784eaa |
conf->collect_struct = 0;
|
|
|
b784eaa |
conf->collect_totals = 0;
|
|
|
b784eaa |
-#ifdef HAVE_VARNISH_V3
|
|
|
b784eaa |
+#if HAVE_VARNISH_V3 || HAVE_VARNISH_V4
|
|
|
b784eaa |
conf->collect_uptime = 0;
|
|
|
b784eaa |
#endif
|
|
|
b784eaa |
conf->collect_vcl = 0;
|
|
|
b784eaa |
conf->collect_workers = 0;
|
|
|
b784eaa |
+#if HAVE_VARNISH_V4
|
|
|
b784eaa |
+ conf->collect_vsm = 0;
|
|
|
b784eaa |
+#endif
|
|
|
b784eaa |
|
|
|
b784eaa |
return (0);
|
|
|
b784eaa |
} /* }}} int varnish_config_apply_default */
|
|
|
b784eaa |
@@ -699,7 +830,7 @@ static int varnish_config_instance (const oconfig_item_t *ci) /* {{{ */
|
|
|
b784eaa |
cf_util_get_boolean (child, &conf->collect_struct);
|
|
|
b784eaa |
else if (strcasecmp ("CollectTotals", child->key) == 0)
|
|
|
b784eaa |
cf_util_get_boolean (child, &conf->collect_totals);
|
|
|
b784eaa |
-#ifdef HAVE_VARNISH_V3
|
|
|
b784eaa |
+#if HAVE_VARNISH_V3 || HAVE_VARNISH_V4
|
|
|
b784eaa |
else if (strcasecmp ("CollectUptime", child->key) == 0)
|
|
|
b784eaa |
cf_util_get_boolean (child, &conf->collect_uptime);
|
|
|
b784eaa |
#endif
|
|
|
b784eaa |
@@ -707,6 +838,10 @@ static int varnish_config_instance (const oconfig_item_t *ci) /* {{{ */
|
|
|
b784eaa |
cf_util_get_boolean (child, &conf->collect_vcl);
|
|
|
b784eaa |
else if (strcasecmp ("CollectWorkers", child->key) == 0)
|
|
|
b784eaa |
cf_util_get_boolean (child, &conf->collect_workers);
|
|
|
b784eaa |
+#if HAVE_VARNISH_V4
|
|
|
b784eaa |
+ else if (strcasecmp ("CollectVSM", child->key) == 0)
|
|
|
b784eaa |
+ cf_util_get_boolean (child, &conf->collect_vsm);
|
|
|
b784eaa |
+#endif
|
|
|
b784eaa |
else
|
|
|
b784eaa |
{
|
|
|
b784eaa |
WARNING ("Varnish plugin: Ignoring unknown "
|
|
|
b784eaa |
@@ -741,11 +876,15 @@ static int varnish_config_instance (const oconfig_item_t *ci) /* {{{ */
|
|
|
b784eaa |
#endif
|
|
|
b784eaa |
&& !conf->collect_struct
|
|
|
b784eaa |
&& !conf->collect_totals
|
|
|
b784eaa |
-#ifdef HAVE_VARNISH_V3
|
|
|
b784eaa |
+#if HAVE_VARNISH_V3 || HAVE_VARNISH_V4
|
|
|
b784eaa |
&& !conf->collect_uptime
|
|
|
b784eaa |
#endif
|
|
|
b784eaa |
&& !conf->collect_vcl
|
|
|
b784eaa |
- && !conf->collect_workers)
|
|
|
b784eaa |
+ && !conf->collect_workers
|
|
|
b784eaa |
+#if HAVE_VARNISH_V4
|
|
|
b784eaa |
+ && !conf->collect_vsm
|
|
|
b784eaa |
+#endif
|
|
|
b784eaa |
+ )
|
|
|
b784eaa |
{
|
|
|
b784eaa |
WARNING ("Varnish plugin: No metric has been configured for "
|
|
|
b784eaa |
"instance \"%s\". Disabling this instance.",
|