summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2019-02-14 08:53:03 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2019-02-14 09:01:50 (GMT)
commit45c6086f8c0c0f6fe1a46b950682abfdbf104687 (patch) (side-by-side diff)
tree61923d59ed3dbbe0365d88e574b7e4f1aec4fbcc
parentdffed71f70f7e7b6bf1cd32539a1a1131916a8b4 (diff)
downloadvarnish-mib-45c6086f8c0c0f6fe1a46b950682abfdbf104687.tar.gz
varnish-mib-45c6086f8c0c0f6fe1a46b950682abfdbf104687.tar.bz2
Rewrite as a stand-alone snmpd agent.
* NEWS: Document new features. * configure.ac: Raise version number. * src/.gitignore: Update. * src/Makefile.am: Build as an agent. * src/main.c: New file. * src/modconf.c: Remove "varnish" prefix from the configuration directives. (varnish_mib_config_init): Use program name as the base for the configuration file name. (varnish_mib_config_help): New function. * src/modconf.h (progname, pid_file, pid_file_immutable): New externs. * src/varnish-mib.8: Rewrite. * src/varnish_mib.mib2c (varnish_snmp_init) (varnish_snmp_deinit): Remove. (post_config): Extern. Called from main().
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--NEWS8
-rw-r--r--configure.ac10
-rw-r--r--src/.gitignore1
-rw-r--r--src/Makefile.am20
-rw-r--r--src/main.c282
-rw-r--r--src/modconf.c54
-rw-r--r--src/modconf.h5
-rw-r--r--src/varnish-mib.8153
-rw-r--r--src/varnish_mib.mib2c30
9 files changed, 451 insertions, 112 deletions
diff --git a/NEWS b/NEWS
index 34ba295..8e0cbb4 100644
--- a/NEWS
+++ b/NEWS
@@ -1,8 +1,12 @@
-Varnish-mib NEWS -- history of user-visible changes. 2018-12-10
+Varnish-mib NEWS -- history of user-visible changes. 2019-02-14
See the end of file for copying conditions.
Please send Varnish-mib bug reports to <gray@gnu.org>
+Version 3.99.90 (git)
+
+Rewrite as a stand-alone snmpd agent.
+
Version 3.1, 2018-12-10
Supports Varnish 6.0.2.
@@ -115,7 +119,7 @@ Initial release.
* Copyright information:
-Copyright (C) 2014-2018 Sergey Poznyakoff
+Copyright (C) 2014-2019 Sergey Poznyakoff
Permission is granted to anyone to make or distribute verbatim copies
of this document as received, in any medium, provided that the
diff --git a/configure.ac b/configure.ac
index f2bca53..af72e65 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
# This file is part of Varnish-mib -*- autoconf -*-
-# Copyright (C) 2014-2018 Sergey Poznyakoff
+# Copyright (C) 2014-2019 Sergey Poznyakoff
#
# Varnish-mib is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -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.1, [gray@gnu.org])
+AC_INIT([varnish-mib], 3.99.90, [gray@gnu.org])
AC_CONFIG_SRCDIR(src/varnish_mib.mib2c)
AM_CONFIG_HEADER(config.h)
AC_CONFIG_AUX_DIR([build-aux])
@@ -50,7 +50,11 @@ AC_PATH_PROG([NET_SNMP_CONFIG], net-snmp-config, none, $PATH)
if test "$NET_SNMP_CONFIG" = "none"; then
AC_MSG_ERROR([cannot find Net-SNMP (net-snmp-config not found)])
fi
-AC_SUBST(NET_SNMP_CONFIG)
+
+AC_SUBST(NET_SNMP_LIBS, `$NET_SNMP_CONFIG --agent-libs`)
+AC_SUBST(NET_SNMP_EXLIBS, `$NET_SNMP_CONFIG --external-libs`)
+AC_SUBST(NET_SNMP_MIBDIRS, `$NET_SNMP_CONFIG --mibdirs`)
+AC_SUBST(NET_SNMP_MIBS, `$NET_SNMP_CONFIG --default-mibs`)
# Checks for header files.
AC_HEADER_STDC
diff --git a/src/.gitignore b/src/.gitignore
index f40282a..e6ff459 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -1,3 +1,4 @@
+varnish-mib
varnish_mib.c
varnish_mib.h
belex.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 5c79dfc..6019c39 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,5 +1,5 @@
# This file is part of varnish-mib -*- automake -*-
-# Copyright (C) 2014-2018 Sergey Poznyakoff
+# Copyright (C) 2014-2019 Sergey Poznyakoff
#
# varnish-mib is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -14,15 +14,14 @@
# You should have received a copy of the GNU General Public License
# along with varnish-mib. If not, see <http://www.gnu.org/licenses/>.
-dlmoddir=@DLMODDIR@
-dlmod_LTLIBRARIES = varnish-mib.la
-
-varnish_mib_la_SOURCES = \
+sbin_PROGRAMS = varnish-mib
+varnish_mib_SOURCES = \
auth.c\
ban.c\
backend.h\
belex.l\
betab.c\
+ main.c\
modconf.h\
modconf.c\
sha256.c\
@@ -44,18 +43,7 @@ varnish_mib.c varnish_mib.h: varnish_mib.mib2c VARNISH-MIB.txt
PERL5LIB=${top_srcdir}/lib \
mib2c -c $< -f $@ varnish
-#NET_SNMP_INCLUDES = `$(NET_SNMP_CONFIG) --cflags`
-#NET_SNMP_INCLUDES =
-NET_SNMP_LIBS = `$(NET_SNMP_CONFIG) --libs`
-NET_SNMP_EXLIBS = `$(NET_SNMP_CONFIG) --external-libs`
-NET_SNMP_MIBDIRS = `net-snmp-config --mibdirs`
-NET_SNMP_MIBS = `net-snmp-config --default-mibs`
-
AM_LDFLAGS = \
- -module \
- -export-dynamic\
- -avoid-version \
- -rpath '$(dlmoddir)'\
${VARNISHAPI_LIBS}\
$(NET_SNMP_LIBS)\
$(NET_SNMP_EXLIBS)
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..a8d089f
--- a/dev/null
+++ b/src/main.c
@@ -0,0 +1,282 @@
+#include "varnish_mib.h"
+#include <unistd.h>
+#include <sys/types.h>
+#include <signal.h>
+
+char *progname;
+
+static void pidfile_check(char const *pid_file);
+static void pidfile_create(char const *pid_file);
+static int pidfile_remove(char const *pid_file);
+
+void
+usage(FILE *fp)
+{
+ fprintf(fp, "usage: varnish-mib [OPTIONS]\n");
+ fprintf(fp, "SNMP agent for Varnish Cache monitoring\n");
+ fprintf(fp, "OPTIONS are:\n\n");
+
+ fprintf(fp,
+ " -A append to the log file rather than truncating it\n");
+ fprintf(fp,
+ " -C do not read any configuration files except the ones optionally\n"
+ " specified by the -c option\n");
+ fprintf(fp,
+ " -D TOKEN[,TOKEN...]\n"
+ " turn on debugging output for the given TOKENs\n");
+ fprintf(fp,
+ " -H display a list of configuration file directives understood\n"
+ " by the agent and then exit\n");
+ fprintf(fp,
+ " -L[efos] configure logging\n");
+ fprintf(fp,
+ " -c FILE ead FILE as a configuration file (or a comma-separated list of\n"
+ " configuration files\n");
+ fprintf(fp,
+ " -d dump (in hexadecimal) the sent and received SNMP packets\n");
+ fprintf(fp,
+ " -f remain in the foreground\n");
+ fprintf(fp,
+ " -h, -? print this help summary\n");
+ fprintf(fp,
+ " -n NAME assume this program name\n");
+ fprintf(fp,
+ " -p save the process ID of the daemon in FILE\n");
+ fprintf(fp, "\n");
+ fprintf(fp, "default configuration path is: %s\n",
+ get_configuration_directory());
+}
+
+static volatile int stop;
+
+static void
+stophandler(int sig)
+{
+ stop = 1;
+}
+
+int
+main(int argc, char **argv)
+{
+ int c, i;
+ int foreground = 0;
+ struct sigaction sa;
+ static int signo[] = {
+ SIGHUP,
+ SIGINT,
+ SIGQUIT,
+ SIGTERM,
+ 0
+ };
+ int log_set = 0;
+ int snmp_dump_packet = 0;
+
+ progname = strrchr(argv[0], '/');
+ if (progname)
+ progname++;
+ else
+ progname = argv[0];
+ if (strncmp(progname, "lt-", 3) == 0)
+ progname += 3;
+
+ while ((c = getopt(argc, argv, "ACD:HL:c:dfhn:p:")) != EOF) {
+ switch (c) {
+ case 'A':
+ netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID,
+ NETSNMP_DS_LIB_APPEND_LOGFILES,
+ 1);
+ break;
+
+ case 'C':
+ netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID,
+ NETSNMP_DS_LIB_DONT_READ_CONFIGS,
+ 1);
+ break;
+
+ case 'D':
+#ifdef NETSNMP_NO_DEBUGGING
+ fprintf(stderr, "%s: debugging not configured\n",
+ progname);
+ exit(1);
+#else
+ debug_register_tokens(optarg);
+ snmp_set_do_debugging(1);
+#endif
+ break;
+
+ case 'H':
+ varnish_mib_config_help();
+ break;
+
+ case 'L':
+ if (snmp_log_options(optarg, argc, argv) < 0) {
+ usage(stderr);
+ }
+ log_set = 1;
+ break;
+
+ case 'c':
+ netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID,
+ NETSNMP_DS_LIB_OPTIONALCONFIG,
+ optarg);
+ break;
+
+ case 'd':
+ netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID,
+ NETSNMP_DS_LIB_DUMP_PACKET,
+ ++snmp_dump_packet);
+ break;
+
+ case 'f':
+ foreground = 1;
+ break;
+
+ case 'n':
+ progname = optarg;
+ break;
+
+ case 'p':
+ pid_file = optarg;
+ pid_file_immutable = 1;
+ break;
+
+ case 'h':
+ usage(stdout);
+ exit(0);
+
+ default:
+ if (optopt == '?') {
+ usage(stdout);
+ exit(0);
+ }
+ fprintf(stderr, "%s: unrecognized option: %c\n",
+ progname, optopt);
+ usage(stderr);
+ exit(1);
+ }
+ }
+
+ netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID,
+ NETSNMP_DS_LIB_APPTYPE, progname);
+
+ netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID,
+ NETSNMP_DS_AGENT_ROLE, 1);
+ SOCK_STARTUP;
+ init_agent(progname);
+ init_varnish_mib();
+ init_snmp(progname);
+ if (post_config())
+ exit(1);
+
+ pidfile_check(pid_file);
+
+ if (!foreground) {
+ int i;
+ if (daemon(0, 1)) {
+ fprintf(stderr, "%s: daemon: %s\n",
+ progname, strerror(errno));
+ exit(1);
+ }
+ openlog(progname, LOG_CONS|LOG_PID, LOG_DAEMON);
+ if (!log_set) {
+ snmp_enable_syslog_ident(progname, LOG_DAEMON);
+ snmp_disable_stderrlog();
+ }
+ } else {
+ if (!log_set)
+ snmp_enable_stderrlog();
+ }
+
+ pidfile_create(pid_file);
+
+ sa.sa_handler = stophandler;
+ sa.sa_flags = 0;
+ sigemptyset (&sa.sa_mask);
+ for (i = 0; signo[i]; i++)
+ sigaction(signo[i], &sa, NULL);
+
+ while (!stop) {
+ agent_check_and_process(1);
+ }
+
+ SOCK_CLEANUP;
+ snmp_shutdown(progname);
+ pidfile_remove(pid_file);
+ return 0;
+}
+
+static int
+pidfile_remove(char const *pid_file)
+{
+ if (pid_file && unlink(pid_file)) {
+ snmp_log(LOG_ERR,
+ "cannot unlink pidfile `%s': %s\n",
+ pid_file,
+ strerror(errno));
+ return 1;
+ }
+ return 0;
+}
+
+static void
+pidfile_create(char const *pid_file)
+{
+ FILE *fp;
+
+ if (!pid_file)
+ return;
+
+ fp = fopen(pid_file, "w");
+ if (!fp) {
+ snmp_log(LOG_CRIT,
+ "cannot create pidfile `%s': %s\n",
+ progname,
+ pid_file,
+ strerror(errno));
+ exit(1);
+ }
+ fprintf(fp, "%lu\n", (unsigned long) getpid());
+ fclose(fp);
+}
+
+/* Check whether pidfile exists and if so, whether its PID is still
+ active. Exit if it is. */
+static void
+pidfile_check(char const *pid_file)
+{
+ unsigned long pid;
+ FILE *fp;
+
+ if (!pid_file)
+ return;
+
+ fp = fopen(pid_file, "r");
+
+ if (fp) {
+ if (fscanf(fp, "%lu", &pid) != 1) {
+ snmp_log(LOG_ERR,
+ "cannot get pid from pidfile `%s'\n",
+ pid_file,
+ strerror(errno));
+ } else {
+ if (kill(pid, 0) == 0) {
+ snmp_log(LOG_ERR,
+ "%s appears to run with pid %lu. "
+ "If it does not, remove `%s' and retry.\n",
+ progname,
+ pid,
+ pid_file);
+ exit(1);
+ }
+ }
+
+ fclose(fp);
+ if (pidfile_remove(pid_file))
+ exit(1);
+ } else if (errno != ENOENT) {
+ snmp_log(LOG_CRIT,
+ "cannot open pidfile `%s': %s\n",
+ pid_file, strerror(errno));
+ exit(1);
+ }
+}
diff --git a/src/modconf.c b/src/modconf.c
index 64177c1..152d488 100644
--- a/src/modconf.c
+++ b/src/modconf.c
@@ -1,5 +1,5 @@
/* This file is part of varnish-mib
- Copyright (C) 2018 Sergey Poznyakoff
+ Copyright (C) 2018-2019 Sergey Poznyakoff
Varnish-mib is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -52,6 +52,8 @@ unsigned vcli_timeout = 5;
unsigned backendTable_timeout = 5;
vcli_sockaddr_t vcli_sockaddr;
char *vcli_secret;
+char *pid_file = NULL;
+int pid_file_immutable = 0;
static void
ban_table_timeout_parser(const char *token, char *line)
@@ -94,6 +96,19 @@ vcli_secret_releaser(void)
{
free(vcli_secret);
}
+
+static void
+pidfile_parser(const char *token, char *line)
+{
+ if (!pid_file_immutable)
+ pid_file = strdup(line);
+}
+
+static void
+pidfile_releaser(void)
+{
+ /* nothing */
+}
struct varnish_mib_config
{
@@ -104,23 +119,28 @@ struct varnish_mib_config
};
static struct varnish_mib_config config[] = {
- { "varnishBanTableTimeout",
- "varnishBanTableTimeout SECONDS",
+ { "banTableTimeout",
+ "SECONDS",
ban_table_timeout_parser },
- { "varnishBackendTableTimeout",
- "varnishBackendTableTimeout SECONDS",
+ { "backendTableTimeout",
+ "SECONDS",
backend_table_timeout_parser },
- { "varnishCLIPortTimeout",
- "varnishCLIPortTimeout SECONDS",
+ { "cliPortTimeout",
+ "SECONDS",
vcli_timeout_parser },
- { "varnishCLISocket",
- "varnishCLISocket ADDRESS[:PORT]",
+ { "CLISocket",
+ "ADDRESS[:PORT]",
vcli_address_parser,
vcli_address_releaser },
- { "varnishCLISecretFile",
- "varnishCLISecretFile FILE",
+ { "CLISecretFile",
+ "FILE",
vcli_secret_parser,
vcli_secret_releaser },
+ { "pidfile",
+ "FILE",
+ pidfile_parser,
+ pidfile_releaser },
+
{ NULL }
};
@@ -129,7 +149,7 @@ varnish_mib_config_init(void)
{
struct varnish_mib_config *cp;
for (cp = config; cp->token; cp++) {
- if (!register_config_handler("snmpd",
+ if (!register_config_handler(progname,
cp->token,
cp->parser,
cp->releaser,
@@ -138,3 +158,13 @@ varnish_mib_config_init(void)
cp->token);
}
}
+
+void
+varnish_mib_config_help(void)
+{
+ int i;
+
+ for (i = 0; config[i].token; i++) {
+ printf("%s %s\n", config[i].token, config[i].help);
+ }
+}
diff --git a/src/modconf.h b/src/modconf.h
index 0a7d8fc..b9d3787 100644
--- a/src/modconf.h
+++ b/src/modconf.h
@@ -1,3 +1,7 @@
+extern char *progname;
+extern char *pid_file;
+extern int pid_file_immutable;
+
extern unsigned banTable_timeout;
extern unsigned vcli_timeout;
extern unsigned backendTable_timeout;
@@ -5,5 +9,6 @@ extern vcli_sockaddr_t vcli_sockaddr;
extern char *vcli_secret;
void varnish_mib_config_init(void);
+void varnish_mib_config_help(void);
diff --git a/src/varnish-mib.8 b/src/varnish-mib.8
index 6458321..0856c69 100644
--- a/src/varnish-mib.8
+++ b/src/varnish-mib.8
@@ -1,5 +1,5 @@
.\" This file is part of Varnish-mib -*- nroff -*-
-.\" Copyright (C) 2014-2018 Sergey Poznyakoff
+.\" Copyright (C) 2014-2019 Sergey Poznyakoff
.\"
.\" Varnish-mib is free software; you can redistribute it and/or modify
.\" it under the terms of the GNU General Public License as published by
@@ -13,22 +13,29 @@
.\"
.\" You should have received a copy of the GNU General Public License
.\" along with Varnish-mib. If not, see <http://www.gnu.org/licenses/>.
-.TH VARNISH-MIB 8 "February 5, 2018" "varnish-mib"
+.TH VARNISH-MIB 8 "February 14, 2019" "varnish-mib"
.SH NAME
-varnish\-mib \- Net-SNMP module for Varnish Cache monitoring
+varnish\-mib \- Net-SNMP agent for Varnish Cache monitoring
.SH SYNOPSIS
-In \fBsnmpd.conf\fR(5):
-.PP
-.B dlmod varnish_mib /usr/lib/snmp/varnish\-mib.so
+\fBvarnish-mib\fR\
+ [\fB\-ACHdfh\fR]\
+ [\fB\-D \ITOKEN\fR[,\fITOKEN\fR...]]\
+ [\fB\-L[eo]\fR]\
+ [\fB\-Lf \fIFILE\fR]\
+ [\fB\-Ls \fIFACILITY\fR]\
+ [\fB\-LE \fIPRI\fR[\fB\-\fIPRI2\fR]]\
+ [\fB\-c \fIFILE\fR]\
+ [\fB\-n \fINAME\fR]\
+ [\fB\-p \fIFILE\fR]
.SH DESCRIPTION
-Dynamically loadable object module for
-.B net-snmp
-that provides access to Varnish Cache statistics. The module is
-loaded into
+An agent for
.BR snmpd (8)
-as shown above (actual path can of course differ, depending on how
-the package was configured). This version is written for Varnish
-\fB5.2.1\fR.
+that provides access to Varnish Cache statistics. To successfully
+couple with the \fBsnmpd\fR the latter must be started with the
+.B \-x
+command line option, or with the \fBmaster agentx\fR directive in
+.BR snmpd.conf (5)
+file.
.PP
The values in the OID branches
.BR client ,
@@ -47,35 +54,25 @@ are obtained using \fBvarnishd\fR administrative interface (similar
to
.BR varnishadm (8)).
.PP
-To retrieve this information, the module must
+To retrieve this information, the agent must
have enough permissions to scan the Varnish management directory and
-read files located in it. This directory is normally named
-\fB/var/lib/varnish/\fIHOSTNAME\fB/_.vsm_mgt\fR, where \fIHOSTNAME\fR
-stands for the server's hostname. Unless
-.BR snmpd (8)
-is run as root, special measures should be undertaken in order to
-grant access rights. For example, if the daemon runs as user
-\fBsnmp\fR, running the following two commands after starting
-\fBvarnishd\fR will do the trick:
-
-.EX
- setfacl -m u:snmp:rx /var/lib/varnish/$(hostname)/_.vsm_mgt
- setfacl -m u:snmp:r /var/lib/varnish/$(hostname)/_.vsm_mgt/*
-.EE
+read files located in it. Normally this means that it must be started
+either as root or as the user
+.B varnishd
+is started as.
.PP
-
-.SH CONFIGURATION OPTIONS
-Configuration statements specific to
+The configuration for
.B varnish\-mib
-must appear in the
-.B snmpd.conf
-file, after the
-.B dlmod
-statement that loads the module.
-.PP
-The following configuration statements are available:
+is read from the file
+.B varnish\-mib.conf
+located in one of the SNMP configuration path directories. The
+following configuration directives are understood:
+.TP
+\fBpidfile\fR \fIFILE\fR
+Upon startup, write the process ID of the \fBvarnish\-mib\fR daemon to
+\fIFILE\fR. See also the \fB\-p\fR command line option, below.
.TP
-\fBvarnishBanTableTimeout\fR \fINUMBER\fR
+\fBbanTableTimeout\fR \fINUMBER\fR
To create \fBbanTable\fR (see below), \fBvarnish_mib\fR connects to
\fBvarnish\fR administration port and issues the \fBban.list\fR
command. To minimize the performance impact, the information obtained
@@ -83,24 +80,42 @@ is cached for a predefined amount of time (60 seconds by default).
This amount (in seconds) is configured by \fBvarnishBanTableTimeout\fR
statement.
.TP
-\fBvarnishBackendTableTimeout\fR \fINUMBER\fR
+\fBbackendTableTimeout\fR \fINUMBER\fR
Update interval for \fBbackendTable\fR. Default is 5 seconds.
.TP
-\fBvarnishCLIPortTimeout\fR \fINUMBER\fR
-Sets timeout for I/O operations with Varnish administrative port.
+\fBcliPortTimeout\fR \fINUMBER\fR
+Set timeout for I/O operations with Varnish administrative port.
Default is 5 seconds.
.PP
The following two statements are not normally needed, but are
provided for completeness sake:
.TP
-\fBvarnishCLISocket\fR \fIADDRESS\fR[:\fIPORT\fR]
-Sets the address of Varnish administrative interface
-socket.
+\fBcliSocket\fR \fIADDRESS\fR[:\fIPORT\fR]
+Set the address of Varnish administrative interface socket.
+.TP
+\fBcliSecretFile\fR \fIFILE\fR
+Set the pathname of the Varnish secret file.
+.SH OPTIONS
+.TP
+.B \-A
+Append to the log file rather than truncating it.
.TP
-\fBvarnishCLISecretFile\fR \fIFILE\fR
-Sets the pathname of the Varnish secret file.
-.SH DEBUGGING
-The module defines the following debugging tokens:
+\fB\-c \fIFILE\fR
+Read \fIFILE\fR as a configuration file (or a comma-separated list of
+configuration files).
+.TP
+.B \-C
+Do not read any configuration files except the ones specified by the
+\fB\-c\fR option.
+.TP
+\fB\-d
+Dump (in hexadecimal) the sent and received SNMP packets.
+.TP
+\fB\-D \ITOKEN\fR[,\fITOKEN\fR...]
+Turn on debugging output for the given TOKEN(s). Special token
+\fIALL\fR produces extremely verbose output. Other tokens available
+are:
+.RS 4
.TP
.B varnish_mib
Produces general debugging information.
@@ -118,6 +133,34 @@ Enables full transcript of varnish CLI session.
.TP
.B varnish_mib:backend
Outputs verbose information about loading the backend information.
+.RE
+.TP
+.B \-f
+Remain in the foreground.
+.TP
+\fB\-h\fR, \fB\-?\fR
+Print a short usage summary and exit.
+.TP
+.B \-H
+Print a list of configuration file directives understood by the agent
+and then exit.
+.TP
+\fB\-Le\fR, \fB\-Lo\fR, \fB\-Lf \fIFILE\fR, \fB\-Ls \fIFACILITY\fR, \fB\-LE \fIPRI\fR[\fB\-\fIPRI2\fR]
+Specify where logging output should be directed (standard error or
+output, to a file or via syslog). See
+.B LOGGING OPTIONS
+in
+.BR snmpcmd (5)
+for details.
+.TP
+\fB\-n \fINAME\fR
+Set an alternative application name (which will affect the
+configuration files loaded). By default it is the same as the name
+of the binary.
+.TP
+\fB\-p \fIFILE\fR
+Save the process ID of the daemon in \fIFILE\fR. This option
+overrides the \fBpidfile\fR configuration directive.
.SH OIDS
The following OIDs are defined in the
.B VARNISH-MIB.txt
@@ -449,19 +492,16 @@ The \fBagent\fR branch is reserved for
implementation-specific management. It is not used currently.
.SH NOTES
The following OIDs were used in Varnish 4. They are no longer
-available in Varnish 5:
+available in newer Varnish releases:
.TP
.B clientRequests411
-Client requests received, subject to 411 errors. This variable is
-available only in Varnish version \fR4.0\fR.
+Client requests received, subject to 411 errors.
.TP
.B clientRequests413
-Client requests received, subject to 413 errors. This variable is
-available only in Varnish version \fR4.0\fR.
+Client requests received, subject to 413 errors.
.TP
.B backendConnUnused
-Number of unused backend connections. This variable is available only
-in Varnish version \fR4.0\fR.
+Number of unused backend connections.
.PP
The OIDs
.B clientRequestsReceived
@@ -471,6 +511,7 @@ return the same value.
.SH "SEE ALSO"
.BR snmpd.conf (5),
.BR snmpd (8),
+.BR snmpcmd (1),
.BR varnish (7),
.BR varnishstat (1).
.SH AUTHORS
@@ -478,7 +519,7 @@ Sergey Poznyakoff
.SH "BUG REPORTS"
Report bugs to <gray@gnu.org>.
.SH COPYRIGHT
-Copyright \(co 2014-2018 Sergey Poznyakoff
+Copyright \(co 2014-2019 Sergey Poznyakoff
.br
.na
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
diff --git a/src/varnish_mib.mib2c b/src/varnish_mib.mib2c
index e8c143f..df8b537 100644
--- a/src/varnish_mib.mib2c
+++ b/src/varnish_mib.mib2c
@@ -1,5 +1,5 @@
# This file is part of varnish-mib -*- c -*-
-# Copyright (C) 2014-2018 Sergey Poznyakoff
+# Copyright (C) 2014-2019 Sergey Poznyakoff
#
# Varnish-mib is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -197,6 +197,10 @@ int varnish_ban(netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests,
struct vsm *vsm);
+void init_$modulename(void);
+void deinit_$modulename(void);
+int post_config(void);
+
@open ${name}@
/* THIS FILE IS GENERATED AUTOMATICALLY. PLEASE DO NOT EDIT. */
@@ -209,7 +213,7 @@ static struct vsc *vsc;
static void dict_load(struct vsc *vsc);
int
-post_config(int majorID, int minorID, void *serverarg, void *clientarg)
+post_config(void)
{
vsm = VSM_New();
if (!vsm) {
@@ -231,21 +235,6 @@ post_config(int majorID, int minorID, void *serverarg, void *clientarg)
return 0;
}
-void
-varnish_snmp_init(void)
-{
- snmp_register_callback(SNMP_CALLBACK_LIBRARY,
- SNMP_CALLBACK_POST_READ_CONFIG,
- post_config,
- NULL);
-}
-
-void
-varnish_snmp_deinit(void)
-{
- /* FIXME? */
-}
-
struct vsm *
varnish_get_vsm_data(void)
{
@@ -675,10 +664,6 @@ initialize_table_$i(void)
void
init_$modulename(void)
{
- if (vsm) {
- snmp_log(LOG_ERR, "%s: can't be loaded twice\n", "$modulename");
- abort();
- }
@foreach $i scalar@
@startperl@
&{$vars{'varnish_translate'}}($vars{'i'});
@@ -716,12 +701,11 @@ $varnish_endif
@foreach $i table@
initialize_table_$i();
@end@
- varnish_snmp_init();
}
void
deinit_$modulename(void)
{
- varnish_snmp_deinit();
+ // FIXME
}
@calldefine ROCOM@

Return to:

Send suggestions and report system problems to the System administrator.