summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--Makefile.am3
-rw-r--r--NEWS3
-rw-r--r--README39
-rw-r--r--configure.ac11
-rw-r--r--init/README64
-rwxr-xr-xinit/debian79
-rwxr-xr-xinit/rh83
-rwxr-xr-xinit/slackware76
-rwxr-xr-xinit/slackware.genrc10
-rw-r--r--init/varnish-mib.service25
-rw-r--r--src/main.c5
11 files changed, 368 insertions, 30 deletions
diff --git a/Makefile.am b/Makefile.am
index cea3646..c30fe58 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,7 +19,8 @@ EXTRA_DIST=\
git2chg.awk\
lib/prereq.pl\
lib/VarnishMib/HashTable.pm\
- lib/VarnishMib/MIBTable.pm
+ lib/VarnishMib/MIBTable.pm\
+ init
.PHONY: ChangeLog
ChangeLog:
diff --git a/NEWS b/NEWS
index 8e0cbb4..eb3d6b3 100644
--- a/NEWS
+++ b/NEWS
@@ -3,9 +3,10 @@ See the end of file for copying conditions.
Please send Varnish-mib bug reports to <gray@gnu.org>
-Version 3.99.90 (git)
+Version 4.0, 2019-02-14
Rewrite as a stand-alone snmpd agent.
+
Version 3.1, 2018-12-10
diff --git a/README b/README
index 22c3844..579989a 100644
--- a/README
+++ b/README
@@ -14,20 +14,20 @@ the section GIT SOURCES, below.
* Overview
-Varnish-mib is a dynamically loadable object module for net-snmp
-snmpd, that provides access to Varnish Cache statistics. It uses
-MIBs from varnishsnmp project (http://varnishsnmp.sourceforge.net).
+Varnish-mib is an agent for net-snmp snmpd daemon, that provides
+access to Varnish Cache statistics. It uses MIBs from varnishsnmp
+project (http://varnishsnmp.sourceforge.net).
This and other versions of Varnish-mib is available for download from
<http://download.gnu.org.ua/release/varnish-mib>. The following table
describes the relation between the release number and the version
of Varnish API version it is written for:
- 1.0, 1.1 Varnish 4.0 and 4.1
- 1.2 Varnish 4.0, 4.1, 5.1
- 2.0 Varnish 5.2.0
- 3.0 Varnish 5.2.1
- 3.1 (this release) Varnish 5.2.1 to 6.0.2
+ 1.0, 1.1 Varnish 4.0 and 4.1
+ 1.2 Varnish 4.0, 4.1, 5.1
+ 2.0 Varnish 5.2.0
+ 3.0 Varnish 5.2.1
+ 3.1, 4.0 (this release) Varnish 5.2.1 to 6.0.2
* Installation
@@ -38,20 +38,29 @@ installed. The installation sequence is as usual:
make
make install
-(the last step normally requires root privileges). For generic
-options to configure, please see the file INSTALL. Package-specific
-options are:
+(the last step normally requires root privileges).
+Read the init/README file to select the initialization script for your
+distribution and install it following the instructions from this file.
-** --with-dlmoddir=DIR
-
-Install varnish_mod.so in DIR. By default it is installed in
-$PREFIX/lib/snmp, where $PREFIX stands for the installation prefix.
+For generic options to configure, please see the file INSTALL.
+Package-specific options are:
** --with-mibdir=DIR
Install MIBs (the file VARNISH-MIB.txt in DIR. By default it is
installed in $prefix/share/snmp.
+To start the daemon, add the following line to your snmpd.conf file:
+
+ master agentx
+
+Then start the agent:
+
+ varnish-mib
+
+See the varnish-mib(8) manual page for detailed discussion of command
+line options and configuration directives available.
+
* GIT SOURCES
If you cloned the sources from GIT, you will need the following
diff --git a/configure.ac b/configure.ac
index af72e65..77fe4e9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -15,7 +15,7 @@
# along with Varnish-mib. If not, see <http://www.gnu.org/licenses/>.
AC_PREREQ(2.69)
-AC_INIT([varnish-mib], 3.99.90, [gray@gnu.org])
+AC_INIT([varnish-mib], [4.0], [gray@gnu.org])
AC_CONFIG_SRCDIR(src/varnish_mib.mib2c)
AM_CONFIG_HEADER(config.h)
AC_CONFIG_AUX_DIR([build-aux])
@@ -64,15 +64,6 @@ AC_C_CONST
AC_TYPE_SIZE_T
# Directories
-AC_SUBST([DLMODDIR],['$(libdir)/snmp'])
-AC_ARG_WITH([dlmoddir],
- [AC_HELP_STRING([--with-dlmoddir=DIR],
- [installation directory for net-snmp loadable agents])],
- [case $withval in
- /*) DLMODDIR=$withval;;
- *) AC_MSG_ERROR([argument to --with-dlmoddir must be absolute pathname])
- esac])
-
AC_SUBST([MIBDIR],['$(datarootdir)/snmp/mibs'])
AC_ARG_WITH([mibdir],
[AC_HELP_STRING([--with-mibdir=DIR],
diff --git a/init/README b/init/README
new file mode 100644
index 0000000..1ceb38b
--- a/dev/null
+++ b/init/README
@@ -0,0 +1,64 @@
+This directory contains start up files for various GNU/Linux distributions:
+
+* slackware
+================
+A traditional rc file for Slackware.
+
+Usage:
+
+1. Install the script
+
+ $ cp slackware /etc/rc.d/rc.varnish-mib
+
+2. Edit /etc/rc.d/rc.local, adding the following line to it:
+
+ /etc/rc.d/rc.varnish-mib start
+
+3. If you have /etc/rc.d/rc.varnish-mib script (recommended), add the
+following line to it:
+
+ /etc/rc.d/rc.varnish-mib stop
+
+4. Finally, start it:
+
+ /etc/rc.d/rc.varnish-mib start
+
+* slackware.genrc
+=================
+Same as above, for those who use the genrc helper. See
+
+ http://www.gnu.org.ua/software/genrc, for documentation and
+ http://git.gnu.org.ua/cgit/genrc.git, for downloads.
+
+* rh
+================
+This script is for Red Hat (Fedora) distributions with SystemV initialization.
+
+Usage:
+
+ $ cp rh /etc/init.d/varnish-mib
+ $ chkconfig --add varnish-mib
+ $ /etc/init.d/varnish-mib start
+
+* debian
+================
+This is for debian-based distributions (Debian, Ubuntu, etc), featuring
+SystemV initialization.
+
+Usage:
+
+ $ cp debian /etc/init.d/varnish-mib
+ $ update-rc.d varnish-mib defaults
+ $ /etc/init.d/varnish-mib start
+
+* varnish-mib.service
+========================
+Service unit file for any distribution running systemd.
+
+Usage:
+
+ $ cp varnish-mib.service /etc/systemd/system/
+ $ systemctl enable varnish-mib
+ $ systemctl start varnish-mib
+
+Hope that helps.
diff --git a/init/debian b/init/debian
new file mode 100755
index 0000000..81f36da
--- a/dev/null
+++ b/init/debian
@@ -0,0 +1,79 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides: varnish-mib
+# Required-Start: snmpd varnish
+# Required-Stop: snmpd varnish
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Manage varnish MIB agent
+### END INIT INFO
+
+# Source function library.
+. /lib/lsb/init-functions
+
+NAME=varnish-mib
+DESC="varnish MIB agent"
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+DAEMON=/usr/sbin/varnish-mib
+PIDFILE=/var/run/$NAME.pid
+CONFIG=
+OPTIONS=
+
+test -x $DAEMON || exit 0
+
+if [ -f /etc/default/$NAME ]; then
+ . /etc/default/$NAME
+fi
+
+if [ -n "$CONFIG" ]; then
+ OPTIONS="$OPTIONS -C -c$CONFIG"
+fi
+
+# Ensure we have a PATH
+export PATH="${PATH:+$PATH:}/usr/sbin:/usr/bin:/sbin:/bin"
+
+start() {
+ log_daemon_msg "Starting $DESC" "$NAME"
+ if start-stop-daemon --start --pidfile=$PIDFILE --quiet \
+ --exec "$DAEMON" -- $OPTIONS -p $PIDFILE; then
+ log_end_msg 0
+ else
+ log_end_msg 1
+ exit 1
+ fi
+}
+stop() {
+ log_daemon_msg "Stopping $DESC" "$NAME"
+ if start-stop-daemon --stop --pidfile=$PIDFILE --quiet \
+ --retry 5 --exec $DAEMON; then
+ log_end_msg 0
+ else
+ log_end_msg 1
+ fi
+}
+restart() {
+ stop
+ sleep 1
+ start
+}
+status() {
+ status_of_proc -p $PIDFILE $DAEMON "$NAME"
+}
+# See how we were called.
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ status)
+ status && exit 0 || exit $?
+ ;;
+ restart|force-reload)
+ restart
+ ;;
+ *)
+ echo >&2 "Usage: $0 {start|stop|restart|force-reload|status|help}"
+ exit 1
+esac
diff --git a/init/rh b/init/rh
new file mode 100755
index 0000000..394d4d6
--- a/dev/null
+++ b/init/rh
@@ -0,0 +1,83 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides: varnish-mib
+# Required-Start: snmpd varnish
+# Required-Stop: snmpd varnish
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Manage varnish MIB agent
+### END INIT INFO
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+NAME=varnish-mib
+DESC="varnish MIB agent"
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+DAEMON=/usr/sbin/varnish-mib
+PIDFILE=/var/run/$NAME.pid
+CONFIG=
+OPTIONS=
+
+test -x $DAEMON || exit 0
+
+%if [ -f /etc/sysconfig/$NAME ]; then
+ . /etc/sysconfig/$NAME
+fi
+
+if [ -n "$CONFIG" ]; then
+ OPTIONS="$OPTIONS -C -c$CONFIG"
+fi
+
+# Ensure we have a PATH
+export PATH="${PATH:+$PATH:}/usr/sbin:/usr/bin:/sbin:/bin"
+
+start() {
+ echo -n $"Starting $DESC: "
+ daemon --pidfile="$PIDFILE" $DAEMON $OPTIONS -p $PIDFILE
+ RETVAL=$?
+ echo
+}
+stop() {
+ echo -n $"Stopping $DESC: "
+ killproc -p ${PIDFILE} $DAEMON
+ RETVAL=$?
+ echo
+ [ $RETVAL = 0 ] && rm -f ${PIDFILE}
+}
+restart() {
+ stop
+ sleep 1
+ start
+}
+
+# See how we were called.
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ status)
+ status -p ${PIDFILE} $DAEMON
+ RETVAL=$?
+ ;;
+ restart)
+ restart
+ ;;
+ condrestart|try-restart)
+ if status -p ${PIDFILE} $DAEMON >&/dev/null; then
+ stop
+ start
+ fi
+ ;;
+ force-reload|reload)
+ restart
+ ;;
+ *)
+ echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|reload|status|help}"
+ RETVAL=2
+esac
+
+exit $RETVAL
diff --git a/init/slackware b/init/slackware
new file mode 100755
index 0000000..db735ea
--- a/dev/null
+++ b/init/slackware
@@ -0,0 +1,76 @@
+#!/bin/sh
+
+DAEMON=/usr/sbin/varnish-mib
+PIDFILE=/var/run/varnish-mib.pid
+OPTIONS=
+
+# 0 - running
+# 1 - not running
+# 2 - in doubt
+varnish_mib_is_running() {
+ if [ -f $PIDFILE ]; then
+ if [ ! -r $PIDFILE ]; then
+ diag="probably running; $PIDFILE exists, but is not readable"
+ return 2
+ else
+ pid=$(head -n 1 $PIDFILE)
+ if [ -z "$pid" ]; then
+ diag="can't read $PIDFILE"
+ return 2
+ else
+ if kill -0 $pid; then
+ diag="$DAEMON running (pid $pid)"
+ return 0
+ else
+ diag="stale pidfile $PIDFILE"
+ rm $PIDFILE
+ return 2
+ fi
+ fi
+ fi
+ else
+ diag="$DAEMON not running"
+ return 1
+ fi
+}
+
+varnish_mib_status() {
+ varnish_mib_is_running
+ echo $diag
+ exit $?
+}
+
+varnish_mib_start() {
+ if varnish_mib_is_running; then
+ echo $diag
+ else
+ $DAEMON $OPTIONS -p $PIDFILE
+ fi
+}
+
+varnish_mib_stop() {
+ if varnish_mib_is_running; then
+ kill -TERM $pid
+ sleep 2
+ if [ -r $PIDFILE ]; then
+ kill -9 $pid
+ rm -f $PIDFILE;
+ fi
+ else
+ echo $diag
+ fi
+}
+
+case "$1" in
+ start)
+ varnish_mib_start;;
+ stop)
+ varnish_mib_stop;;
+ restart)
+ varnish_mib_restart;;
+ status)
+ varnish_mib_status;;
+ *)
+ echo "usage: $0 start|stop|restart|status"
+esac
+
diff --git a/init/slackware.genrc b/init/slackware.genrc
new file mode 100755
index 0000000..c2180bf
--- a/dev/null
+++ b/init/slackware.genrc
@@ -0,0 +1,10 @@
+#! /bin/sh
+COMMAND=/usr/sbin/varnish-mib
+PIDFILE=/var/run/varnish-mib.pid
+OPTIONS=
+
+exec /sbin/genrc --command "$COMMAND $OPTIONS -p $PIDFILE" \
+ --pidfile $PIDFILE \
+ --no-reload \
+ --verbose \
+ "$@"
diff --git a/init/varnish-mib.service b/init/varnish-mib.service
new file mode 100644
index 0000000..cce3ecc
--- a/dev/null
+++ b/init/varnish-mib.service
@@ -0,0 +1,25 @@
+# Systemd service file for varnish-mib
+# Usage:
+# 1. Copy to /etc/systemd/system/
+# 2. [Optional] Verify using
+# systemd-analyze verify varnish-mib.service
+# 3. Enable/disable:
+# systemctl enable|disable varnish-mib
+# 4. Normal operations
+# systemctl status|start|stop varnish-mib
+# 5. After any modifications to the file, run
+# systemctl daemon-reload
+[Unit]
+Description=Varnish MIB SNMP agent
+After=varnish.service
+After=snmpd.service
+
+[Service]
+Type=forking
+ExecStart=/usr/sbin/varnish-mib -p /var/run/varnish-mib.pid
+PIDFile=/var/run/varnish-mib.pid
+Restart=on-failure
+RestartSec=10
+
+[Install]
+WantedBy=multi-user.target \ No newline at end of file
diff --git a/src/main.c b/src/main.c
index 01a24a9..13d9818 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2,6 +2,7 @@
#include <unistd.h>
#include <sys/types.h>
#include <signal.h>
+#include <string.h>
char *progname;
@@ -174,7 +175,6 @@ main(int argc, char **argv)
pidfile_check(pid_file);
if (!foreground) {
- int i;
if (daemon(0, 1)) {
fprintf(stderr, "%s: daemon: %s\n",
progname, strerror(errno));
@@ -230,7 +230,6 @@ pidfile_create(char const *pid_file)
if (!fp) {
snmp_log(LOG_CRIT,
"cannot create pidfile `%s': %s\n",
- progname,
pid_file,
strerror(errno));
exit(1);
@@ -255,7 +254,7 @@ pidfile_check(char const *pid_file)
if (fp) {
if (fscanf(fp, "%lu", &pid) != 1) {
snmp_log(LOG_ERR,
- "cannot get pid from pidfile `%s'\n",
+ "cannot get pid from pidfile `%s': %s\n",
pid_file,
strerror(errno));
} else {

Return to:

Send suggestions and report system problems to the System administrator.