git.lirion.de

Of git, get, and gud

summaryrefslogtreecommitdiffstats
path: root/nagios-plugins-contrib-24.20190301~bpo9+1/debian/patches/check_varnish
diff options
context:
space:
mode:
Diffstat (limited to 'nagios-plugins-contrib-24.20190301~bpo9+1/debian/patches/check_varnish')
-rw-r--r--nagios-plugins-contrib-24.20190301~bpo9+1/debian/patches/check_varnish/fix_for_v56186
1 files changed, 186 insertions, 0 deletions
diff --git a/nagios-plugins-contrib-24.20190301~bpo9+1/debian/patches/check_varnish/fix_for_v56 b/nagios-plugins-contrib-24.20190301~bpo9+1/debian/patches/check_varnish/fix_for_v56
new file mode 100644
index 0000000..91c93fb
--- /dev/null
+++ b/nagios-plugins-contrib-24.20190301~bpo9+1/debian/patches/check_varnish/fix_for_v56
@@ -0,0 +1,186 @@
+From d53252d965aaa1889a8b56a681c464c6ca04f632 Mon Sep 17 00:00:00 2001
+From: Jean-Louis Dupond <jean-louis@dupond.be>
+Date: Sat, 23 Dec 2017 13:06:01 +0100
+Subject: [PATCH] Switch to new functions for Varnish 5.2
+
+---
+ check_varnish.c | 54 +++++++++++++++++++++++++++++++++++++++++--------
+ configure.ac | 18 ++++++++++-------
+ 2 files changed, 57 insertions(+), 15 deletions(-)
+
+diff --git a/check_varnish/src/check_varnish.c b/check_varnish/src/check_varnish.c
+index 809657c..83aacdc 100644
+--- a/check_varnish/src/check_varnish.c
++++ b/check_varnish/src/check_varnish.c
+@@ -43,7 +43,7 @@
+ #include <locale.h>
+ #include <assert.h>
+
+-#if defined(HAVE_VARNISHAPI_4) || defined(HAVE_VARNISHAPI_4_1)
++#if defined(HAVE_VARNISHAPI_4) || defined(HAVE_VARNISHAPI_4_1) || defined(HAVE_VARNISHAPI_5)
+ #include <vapi/vsc.h>
+ #include <vapi/vsm.h>
+ #elif defined(HAVE_VARNISHAPI_3)
+@@ -185,7 +185,11 @@ check_stats_cb(void *priv, const struct VSC_point * const pt)
+ if (pt == NULL)
+ return(0);
+
+-#if defined(HAVE_VARNISHAPI_4_1) || defined(HAVE_VARNISHAPI_4)
++#if defined(HAVE_VARNISHAPI_5)
++ assert(sizeof(tmp) > (strlen(pt->name) + 1));
++ snprintf(tmp, sizeof(tmp), "%s", pt->name);
++ p = priv;
++#elif defined(HAVE_VARNISHAPI_4_1) || defined(HAVE_VARNISHAPI_4)
+ assert(sizeof(tmp) > (strlen(pt->section->fantom->type) + 1 +
+ strlen(pt->section->fantom->ident) + 1 +
+ strlen(pt->desc->name) + 1));
+@@ -197,7 +201,9 @@ check_stats_cb(void *priv, const struct VSC_point * const pt)
+ pt->desc->name);
+ p = priv;
+ #endif
+-#if defined(HAVE_VARNISHAPI_4_1)
++#if defined(HAVE_VARNISHAPI_5)
++ assert(!strcmp(pt->ctype, "uint64_t"));
++#elif defined(HAVE_VARNISHAPI_4_1)
+ assert(!strcmp(pt->desc->ctype, "uint64_t"));
+ #elif defined(HAVE_VARNISHAPI_4)
+ assert(!strcmp(pt->desc->fmt, "uint64_t"));
+@@ -216,7 +222,9 @@ check_stats_cb(void *priv, const struct VSC_point * const pt)
+ #endif
+ if (strcmp(tmp, p->param) == 0) {
+ p->found = 1;
+-#if defined(HAVE_VARNISHAPI_4) || defined(HAVE_VARNISHAPI_4_1)
++#if defined(HAVE_VARNISHAPI_5)
++ p->info = pt->sdesc;
++#elif defined(HAVE_VARNISHAPI_4) || defined(HAVE_VARNISHAPI_4_1)
+ p->info = pt->desc->sdesc;
+ #elif defined(HAVE_VARNISHAPI_3)
+ p->info = pt->desc;
+@@ -237,7 +245,11 @@ check_stats_cb(void *priv, const struct VSC_point * const pt)
+ * Check the statistics for the requested parameter.
+ */
+ static void
++#if defined(HAVE_VARNISHAPI_5)
++check_stats(struct vsc *vsc, struct vsm *vsm, char *param)
++#else
+ check_stats(struct VSM_data *vd, char *param)
++#endif
+ {
+ int status;
+ struct stat_priv priv;
+@@ -245,7 +257,9 @@ check_stats(struct VSM_data *vd, char *param)
+ priv.found = 0;
+ priv.param = param;
+
+-#if defined(HAVE_VARNISHAPI_4) || defined(HAVE_VARNISHAPI_4_1)
++#if defined(HAVE_VARNISHAPI_5)
++ (void)VSC_Iter(vsc, vsm, check_stats_cb, &priv);
++#elif defined(HAVE_VARNISHAPI_4) || defined(HAVE_VARNISHAPI_4_1)
+ (void)VSC_Iter(vd, NULL, check_stats_cb, &priv);
+ #elif defined(HAVE_VARNISHAPI_3)
+ (void)VSC_Iter(vd, check_stats_cb, &priv);
+@@ -315,18 +329,25 @@ usage(void)
+ int
+ main(int argc, char **argv)
+ {
++#if defined(HAVE_VARNISHAPI_5)
++ struct vsm *vd;
++ struct vsc *vsc;
++#else
+ struct VSM_data *vd;
++#endif
+ char *param = NULL;
+ int opt;
+
+ setlocale(LC_ALL, "");
+
+ vd = VSM_New();
+-#if defined(HAVE_VARNISHAPI_3)
++#if defined(HAVE_VARNISHAPI_5)
++ vsc = VSC_New();
++#elif defined(HAVE_VARNISHAPI_3)
+ VSC_Setup(vd);
+ #endif
+
+- while ((opt = getopt(argc, argv, VSC_ARGS "c:hn:p:vw:")) != -1) {
++ while ((opt = getopt(argc, argv, "c:hn:p:vw:")) != -1) {
+ switch (opt) {
+ case 'c':
+ if (parse_range(optarg, &critical) != 0)
+@@ -336,7 +357,11 @@ main(int argc, char **argv)
+ help();
+ break;
+ case 'n':
++#if defined(HAVE_VARNISHAPI_5)
++ VSC_Arg(vsc, opt, optarg);
++#else
+ VSC_Arg(vd, opt, optarg);
++#endif
+ break;
+ case 'p':
+ param = strdup(optarg);
+@@ -349,13 +374,22 @@ main(int argc, char **argv)
+ usage();
+ break;
+ default:
++#if defined(HAVE_VARNISHAPI_5)
++ if (VSC_Arg(vsc, opt, optarg) > 0)
++#else
+ if (VSC_Arg(vd, opt, optarg) > 0)
++#endif
+ break;
+ usage();
+ }
+ }
+
+-#if defined(HAVE_VARNISHAPI_4) || defined(HAVE_VARNISHAPI_4_1)
++#if defined(HAVE_VARNISHAPI_5)
++ if (VSM_Attach(vd, -1) < 0) {
++ printf("varnish plugin: Cannot attach to varnish. %s", VSM_Error(vd));
++ exit(1);
++ }
++#elif defined(HAVE_VARNISHAPI_4) || defined(HAVE_VARNISHAPI_4_1)
+ if (VSM_Open(vd))
+ exit(1);
+ #elif defined(HAVE_VARNISHAPI_3)
+@@ -377,7 +411,11 @@ main(int argc, char **argv)
+ if (!param)
+ usage();
+
++#if defined(HAVE_VARNISHAPI_5)
++ check_stats(vsc, vd, param);
++#else
+ check_stats(vd, param);
++#endif
+
+ exit(0);
+ }
+diff --git a/check_varnish/src/configure.ac b/check_varnish/src/configure.ac
+index c7946c2..8b0b2ec 100644
+--- a/check_varnish/src/configure.ac
++++ b/check_varnish/src/configure.ac
+@@ -21,13 +21,17 @@ AC_PROG_LIBTOOL
+ AC_PROG_MAKE_SET
+
+ # Checks for libraries.
+-PKG_CHECK_MODULES([VARNISHAPI], [varnishapi >= 4.1],
+- [AC_DEFINE([HAVE_VARNISHAPI_4_1], [1], [Use VARNISHAPI v4.1])],
+- [PKG_CHECK_MODULES([VARNISHAPI], [varnishapi >= 4],
+- [AC_DEFINE([HAVE_VARNISHAPI_4], [1], [Use VARNISHAPI v4])],
+- [PKG_CHECK_MODULES([VARNISHAPI], [varnishapi >= 3],
+- [AC_DEFINE([HAVE_VARNISHAPI_3], [1], [Use VARNISHAPI v3])],
+- [AC_MSG_ERROR([Could not find neither varnishapi v4 nor v3.])])
++PKG_CHECK_MODULES([VARNISHAPI], [varnishapi >= 5.2],
++ [AC_DEFINE([HAVE_VARNISHAPI_5], [1], [Use VARNISHAPI v5])],
++ [PKG_CHECK_MODULES([VARNISHAPI], [varnishapi >= 4.1],
++ [AC_DEFINE([HAVE_VARNISHAPI_4_1], [1], [Use VARNISHAPI v4.1])],
++ [PKG_CHECK_MODULES([VARNISHAPI], [varnishapi >= 4],
++ [AC_DEFINE([HAVE_VARNISHAPI_4], [1], [Use VARNISHAPI v4])],
++ [PKG_CHECK_MODULES([VARNISHAPI], [varnishapi >= 3],
++ [AC_DEFINE([HAVE_VARNISHAPI_3], [1], [Use VARNISHAPI v3])],
++ [AC_MSG_ERROR([Could not find neither varnishapi v4 nor v3.])])
++ ]
++ )
+ ]
+ )
+ ]