summaryrefslogtreecommitdiffabout
path: root/src
authorSergey Poznyakoff <gray@gnu.org.ua>2014-11-26 22:47:17 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2014-11-26 22:47:17 (GMT)
commit4090bd6ff268036b5fd1fdb0fe6d344fd25b5198 (patch) (side-by-side diff)
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') (more/less context) (ignore whitespace changes)
-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
@@ -64,8 +64,8 @@ varnish_ban(netsnmp_agent_request_info *reqinfo,
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);
@@ -76,20 +76,27 @@ varnish_ban_table_timeout_parser(const char *token, char *line)
++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
@@ -100,7 +107,7 @@ varnish_ban_table_timeout_set(netsnmp_agent_request_info *reqinfo,
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
@@ -13,13 +13,13 @@
.\"
.\" 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
@@ -28,6 +28,14 @@ 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
@@ -36,6 +44,8 @@ must appear in the
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
@@ -47,6 +57,10 @@ 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
@@ -75,7 +89,7 @@ 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
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
@@ -166,13 +166,16 @@ 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. */
@@ -314,7 +317,7 @@ handle_$i(netsnmp_mib_handler *handler,
@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;
@@ -527,7 +530,13 @@ init_$modulename(void)
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,
diff --git a/src/vcli.c b/src/vcli.c
index ba9bd65..6e7bbec 100644
--- a/src/vcli.c
+++ b/src/vcli.c
@@ -27,7 +27,13 @@
#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

Return to:

Send suggestions and report system problems to the System administrator.