aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2014-11-27 00:47:17 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2014-11-27 00:47:17 +0200
commit4090bd6ff268036b5fd1fdb0fe6d344fd25b5198 (patch)
treef75281343a2ec3be4061acf02fca828a901dc65c /src
parent039fcda402493c6083a219dd6df8b8c6078d2390 (diff)
downloadvarnish-mib-4090bd6ff268036b5fd1fdb0fe6d344fd25b5198.tar.gz
varnish-mib-4090bd6ff268036b5fd1fdb0fe6d344fd25b5198.tar.bz2
Make varnish CLI timeout configurable.
* src/ban.c (varnish_mib_timeout_parser): New function. * src/varnish_mib.mib2c (varnish_mib_timeout_parser): New proto. (init_$modulename): Register config handler for varnishCLIPortTimeout. * src/vcli.c (vcli_timeout): Change type to unsigned. (varnish_vcli_timeout_parser): New function. * src/varnish-mib.8: Update.
Diffstat (limited to 'src')
-rw-r--r--src/ban.c21
-rw-r--r--src/varnish-mib.824
-rw-r--r--src/varnish_mib.mib2c15
-rw-r--r--src/vcli.c8
4 files changed, 52 insertions, 16 deletions
diff --git a/src/ban.c b/src/ban.c
index 4648f59..72aa506 100644
--- a/src/ban.c
+++ b/src/ban.c
@@ -61,49 +61,56 @@ varnish_ban(netsnmp_agent_request_info *reqinfo,
free(expr);
return rc ? SNMP_ERR_GENERR : SNMP_ERR_NOERROR;
}
unsigned banTable_timeout = 60;
-void
-varnish_ban_table_timeout_parser(const char *token, char *line)
+int
+varnish_mib_timeout_parser(const char *token, char *line, unsigned *retval)
{
char *p;
unsigned long n = strtoul(line, &p, 10);
if (*p) {
if (isspace(*p)) {
while (*p && isspace(*p))
++p;
if (*p) {
config_perror("too many arguments");
- return;
+ return 1;
}
} else {
config_perror("invalid timeout value");
- return;
+ return 1;
}
}
if (n > UINT_MAX) {
config_perror("timeout value out of allowed range");
- return;
+ return 1;
}
- banTable_timeout = n;
+ *retval = n;
+ return 0;
+}
+
+void
+varnish_ban_table_timeout_parser(const char *token, char *line)
+{
+ varnish_mib_timeout_parser(token, line, &banTable_timeout);
}
int
varnish_ban_table_timeout_set(netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests,
struct VSM_data *vd)
{
if (*requests->requestvb->val.integer < 0 ||
*requests->requestvb->val.integer > UINT_MAX)
return SNMP_ERR_BADVALUE;
- DEBUGMSGTL(("varnish_ban", "setting banTable timeould %ld\n",
+ DEBUGMSGTL(("varnish_ban", "setting banTable timeout %ld\n",
*requests->requestvb->val.integer));
banTable_timeout = *requests->requestvb->val.integer;
return SNMP_ERR_NOERROR;
}
/*
diff --git a/src/varnish-mib.8 b/src/varnish-mib.8
index af82000..e45ed0d 100644
--- a/src/varnish-mib.8
+++ b/src/varnish-mib.8
@@ -10,46 +10,60 @@
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
.\" GNU General Public License for more details.
.\"
.\" 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 "November 26, 2014" "varnish-mib"
+.TH VARNISH-MIB 8 "November 27, 2014" "varnish-mib"
.SH NAME
-varnish\-mib \- net\-snmp module for obtaining Varnish Cache statistics
+varnish\-mib \- net-snmp module for obtaining Varnish Cache statistics
.SH SYNOPSIS
In \fBsnmpd.conf\fR(5):
-.br
-.B dlmod varnish_mib /usr/lib/snmp/varnish-mib.so
+.PP
+.B dlmod varnish_mib /usr/lib/snmp/varnish\-mib.so
.SH DESCRIPTION
Dynamically loadable object module for
.B net-snmp
that provides access to Varnish Cache statistics. The module is
loaded into
.BR snmpd (8)
as shown above (actual path can of course differ, depending on how
the package was configured).
+.PP
+The module obtains most of the data using Varnish API. Information
+about available bans (\fBbanTable\fR subtree) as well as the mechanism
+for setting bans (\fBclientBan\fR OID) are implemented via \fBvarnishd\fR
+administrative interface. For these to work, the module must have
+read access to Varnish secret file. In other words, the secret file
+must be readable either by the user \fBsnmpd\fR runs as, or by one
+of this user's groups.
.SH CONFIGURATION OPTIONS
Configuration statements specific to
.B varnish\-mib
must appear in the
.B snmpd.conf
file below the
.B dlmod
statement that loads the module.
+.PP
+The following configuration statements are available:
.TP
\fBvarnishBanTableTimeout\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
is cached for a predefined amount of time (60 seconds by default).
This amount (in seconds) is configured by \fBvarnishBanTableTimeout\fR
statement.
It can also be set remotely by assigning new value to the
\fBbanTableTimeout\fR oid.
+.TP
+\fBvarnishCLIPortTimeout\fR \fINUMBER\fR
+Sets timeout for I/O operations with Varnish administrative port.
+Default is 5 seconds.
.SH OIDS
The following OIDs are defined:
.SS Branch \(dqclient\(dq
.TP
.B clientAcceptedConnections
Number of accepted connections.
@@ -72,13 +86,13 @@ the backend before delivering it to the client.
.B clientBan
A write-only OID. When set, invalidates the cache using the supplied
value as argument to ban. When read, returns an empty string. E.g.,
to invalidate caches of all \fBpng\fR images:
.EE
-snmpset \fBhostname\fR VARNISH-MIB::clientBan.0 s 'req.url ~ \(dq.png$\(dq'
+snmpset \fBhostname\fR VARNISH\-MIB::clientBan.0 s 'req.url ~ \(dq\\.png$\(dq'
.EX
.SS Branch \(dqbackend\(dq
.TP
.B backendConnSuccess
Number of successful connections to the backend.
.TP
diff --git a/src/varnish_mib.mib2c b/src/varnish_mib.mib2c
index b20074c..819ef1c 100644
--- a/src/varnish_mib.mib2c
+++ b/src/varnish_mib.mib2c
@@ -163,19 +163,22 @@ int varnish_auth_response(const char *file, const char *challenge,
char response[CLI_AUTH_RESPONSE_LEN + 1]);
int varnish_ban(netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests,
struct VSM_data *vd);
+int varnish_mib_timeout_parser(const char *token, char *line,
+ unsigned *retval);
+
extern unsigned banTable_timeout;
void varnish_ban_table_timeout_parser(const char *token, char *line);
+void varnish_vcli_timeout_parser(const char *token, char *line);
int varnish_ban_table_timeout_set(netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests,
struct VSM_data *vd);
-int varnish_ban_table_timeout_get(void **valptr, size_t *valsize);
@open ${name}@
/* THIS FILE IS GENERATED AUTOMATICALLY. PLEASE DO NOT EDIT. */
#include "varnish_mib.h"
@@ -311,13 +314,13 @@ handle_$i(netsnmp_mib_handler *handler,
break;
case MODE_SET_FREE:
@if $varnish_set_free ne ''@
# Free resources allocated in RESERVE1 and/or
# RESERVE2. Something failed somewhere, and the states
- # below won't be called. */
+ # below won't be called.
$varnish_set_free(reqinfo, requests, vd);
@end@
break;
case MODE_SET_ACTION:
@if $varnish_set_action ne ''@
@@ -524,13 +527,19 @@ init_$modulename(void)
if (!register_config_handler("snmpd", "varnishBanTableTimeout",
varnish_ban_table_timeout_parser,
NULL,
"varnishBanTableTimeout SECONDS"))
snmp_log(LOG_ERR,"can't register config handler\n");
-
+
+ if (!register_config_handler("snmpd", "varnishCLIPortTimeout",
+ varnish_vcli_timeout_parser,
+ NULL,
+ "varnishCLIPortTimeout SECONDS"))
+ snmp_log(LOG_ERR,"can't register config handler\n");
+
@foreach $i scalar@
netsnmp_register_scalar(
netsnmp_create_handler_registration("$i", handle_$i,
${i}_oid, OID_LENGTH(${i}_oid),
@if !$i.settable@
HANDLER_CAN_RONLY
diff --git a/src/vcli.c b/src/vcli.c
index ba9bd65..6e7bbec 100644
--- a/src/vcli.c
+++ b/src/vcli.c
@@ -24,13 +24,19 @@
#include <netdb.h>
#include <arpa/inet.h>
#include <errno.h>
#define ISSPACE(c) ((c)==' '||(c)=='\t'||(c)=='\n')
-unsigned long vcli_timeout = 5; /* FIXME */
+static unsigned vcli_timeout = 5;
+
+void
+varnish_vcli_timeout_parser(const char *token, char *line)
+{
+ varnish_mib_timeout_parser(token, line, &vcli_timeout);
+}
#define VCLI_INIT_ALLOC 16
static int
vcli_alloc(struct vcli_conn *conn, size_t size)
{

Return to:

Send suggestions and report system problems to the System administrator.