[packages/nagios-plugin-check_varnish] Rel 3
arekm
arekm at pld-linux.org
Sat Aug 22 22:33:30 CEST 2026
commit 7cf0894ed4494b60314cf425e8eadac63848488b
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Sat Aug 22 22:33:22 2026 +0200
Rel 3
nagios-plugin-check_varnish.spec | 25 ++++--
stat-priv-init.patch | 11 +++
varnishapi5.patch | 169 +++++++++++++++++++++++++++++++++++++++
3 files changed, 198 insertions(+), 7 deletions(-)
---
diff --git a/nagios-plugin-check_varnish.spec b/nagios-plugin-check_varnish.spec
index 76b14b8..5164086 100644
--- a/nagios-plugin-check_varnish.spec
+++ b/nagios-plugin-check_varnish.spec
@@ -1,21 +1,25 @@
%define plugin check_varnish
+%define gitref 672523d965dbcb8d5fd9770ac4b2ab3180f9939d
Summary: Nagios plugin to monitor Varnish instances
Name: nagios-plugin-%{plugin}
Version: 1.1
-Release: 2
+Release: 3
License: BSD
Group: Networking
-Source0: http://repo.varnish-cache.org/source/varnish-nagios-%{version}.tar.gz
-# Source0-md5: d9a5477f9143187ffe6314ddecb03015
+Source0: https://github.com/varnish/varnish-nagios/archive/%{gitref}/varnish-nagios-%{version}-%{gitref}.tar.gz
+# Source0-md5: b93cb0fb7d41beb275d0aa9effc444fa
Source1: %{plugin}.cfg
-URL: http://www.varnish-cache.org/
+Patch0: varnishapi5.patch
+Patch1: stat-priv-init.patch
+URL: https://github.com/varnish/varnish-nagios
+BuildRequires: autoconf >= 2.59
+BuildRequires: automake
+BuildRequires: libtool
BuildRequires: pkgconfig
BuildRequires: varnish-devel
Requires: nagios-common
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
-%undefine __cxx
-
%define _sysconfdir /etc/nagios/plugins
%define plugindir %{_prefix}/lib/nagios/plugins
@@ -23,9 +27,16 @@ BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
Nagios plugin to check Varnish.
%prep
-%setup -qn varnish-nagios-%{version}
+%setup -qn varnish-nagios-%{gitref}
+%patch -P0 -p1
+%patch -P1 -p1
%build
+%{__libtoolize}
+%{__aclocal}
+%{__autoconf}
+%{__autoheader}
+%{__automake}
%configure
%{__make}
diff --git a/stat-priv-init.patch b/stat-priv-init.patch
new file mode 100644
index 0000000..2ec9b8f
--- /dev/null
+++ b/stat-priv-init.patch
@@ -0,0 +1,11 @@
+--- varnish-nagios.orig/check_varnish.c 2026-08-22 22:05:53.719914040 +0200
++++ varnish-nagios/check_varnish.c 2026-08-22 22:05:53.791632817 +0200
+@@ -262,7 +262,7 @@
+ int status;
+ struct stat_priv priv;
+
+- priv.found = 0;
++ memset(&priv, 0, sizeof(priv));
+ priv.param = param;
+
+ #if defined(HAVE_VARNISHAPI_5)
diff --git a/varnishapi5.patch b/varnishapi5.patch
new file mode 100644
index 0000000..42830c0
--- /dev/null
+++ b/varnishapi5.patch
@@ -0,0 +1,169 @@
+--- varnish-nagios.orig/check_varnish.c 2026-08-22 22:03:40.983247372 +0200
++++ varnish-nagios/check_varnish.c 2026-08-22 22:03:40.983247372 +0200
+@@ -43,7 +43,8 @@
+ #include <locale.h>
+ #include <assert.h>
+
+-#if defined(HAVE_VARNISHAPI_4) || defined(HAVE_VARNISHAPI_4_1)
++#if defined(HAVE_VARNISHAPI_5) || defined(HAVE_VARNISHAPI_4) || \
++ defined(HAVE_VARNISHAPI_4_1)
+ #include <vapi/vsc.h>
+ #include <vapi/vsm.h>
+ #elif defined(HAVE_VARNISHAPI_3)
+@@ -51,6 +52,13 @@
+ #include "varnishapi.h"
+ #endif
+
++#if defined(HAVE_VARNISHAPI_5)
++/* 5.0 split struct VSM_data into separate VSM and VSC handles */
++static struct vsc *vsc;
++/* VSC_ARGS is gone; -f/-I/-X/-R/-r are VSC args, -t is a VSM arg */
++#define VSC_ARGS "f:I:X:R:rt:"
++#endif
++
+ static int verbose = 0;
+
+ struct range {
+@@ -185,6 +193,12 @@
+ if (pt == NULL)
+ return(0);
+
++#if defined(HAVE_VARNISHAPI_5)
++ assert(sizeof(tmp) > strlen(pt->name) + 1);
++ snprintf(tmp, sizeof(tmp), "%s", pt->name);
++ p = priv;
++ assert(!strcmp(pt->ctype, "uint64_t"));
++#endif
+ #if defined(HAVE_VARNISHAPI_4_1) || defined(HAVE_VARNISHAPI_4)
+ assert(sizeof(tmp) > (strlen(pt->section->fantom->type) + 1 +
+ strlen(pt->section->fantom->ident) + 1 +
+@@ -216,7 +230,9 @@
+ #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 +253,11 @@
+ * Check the statistics for the requested parameter.
+ */
+ static void
++#if defined(HAVE_VARNISHAPI_5)
++check_stats(struct vsm *vd, char *param)
++#else
+ check_stats(struct VSM_data *vd, char *param)
++#endif
+ {
+ int status;
+ struct stat_priv priv;
+@@ -245,7 +265,9 @@
+ 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, vd, 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);
+@@ -292,7 +314,7 @@
+ " hits + misses. Default thresholds are 95 and 90.\n"
+ "usage Cache file usage as a percentage of the total cache space.\n"
+ "\n"
+- "Examples for Varnish 4.x:\n"
++ "Examples for Varnish 4.x and newer:\n"
+ "\n"
+ "ratio The cache hit ratio expressed as a percentage of hits to\n"
+ " hits + misses. Default thresholds are 95 and 90.\n"
+@@ -315,14 +337,20 @@
+ int
+ main(int argc, char **argv)
+ {
++#if defined(HAVE_VARNISHAPI_5)
++ struct vsm *vd;
++#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
+
+@@ -336,7 +364,12 @@
+ help();
+ break;
+ case 'n':
++#if defined(HAVE_VARNISHAPI_5)
++ if (VSM_Arg(vd, opt, optarg) <= 0)
++ usage();
++#else
+ VSC_Arg(vd, opt, optarg);
++#endif
+ break;
+ case 'p':
+ param = strdup(optarg);
+@@ -349,13 +382,23 @@
+ usage();
+ break;
+ default:
++#if defined(HAVE_VARNISHAPI_5)
++ if (VSC_Arg(vsc, opt, optarg) > 0)
++ break;
++ if (VSM_Arg(vd, opt, optarg) > 0)
++ break;
++#else
+ if (VSC_Arg(vd, opt, optarg) > 0)
+ break;
++#endif
+ usage();
+ }
+ }
+
+-#if defined(HAVE_VARNISHAPI_4) || defined(HAVE_VARNISHAPI_4_1)
++#if defined(HAVE_VARNISHAPI_5)
++ if (VSM_Attach(vd, -1))
++ exit(1);
++#elif defined(HAVE_VARNISHAPI_4) || defined(HAVE_VARNISHAPI_4_1)
+ if (VSM_Open(vd))
+ exit(1);
+ #elif defined(HAVE_VARNISHAPI_3)
+--- varnish-nagios.orig/configure.ac 2026-08-22 22:03:40.983247372 +0200
++++ varnish-nagios/configure.ac 2026-08-22 22:03:40.986580706 +0200
+@@ -21,13 +21,17 @@
+ 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],
++ [AC_DEFINE([HAVE_VARNISHAPI_5], [1], [Use VARNISHAPI v5 or newer])],
++ [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 varnishapi v5, v4 nor v3.])])
++ ]
++ )
+ ]
+ )
+ ]
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/nagios-plugin-check_varnish.git/commitdiff/7cf0894ed4494b60314cf425e8eadac63848488b
More information about the pld-cvs-commit
mailing list