diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2014-11-27 00:47:17 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2014-11-27 00:47:17 +0200 |
commit | 4090bd6ff268036b5fd1fdb0fe6d344fd25b5198 (patch) | |
tree | f75281343a2ec3be4061acf02fca828a901dc65c | |
parent | 039fcda402493c6083a219dd6df8b8c6078d2390 (diff) | |
download | varnish-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.
-rw-r--r-- | src/ban.c | 21 | ||||
-rw-r--r-- | src/varnish-mib.8 | 24 | ||||
-rw-r--r-- | src/varnish_mib.mib2c | 15 | ||||
-rw-r--r-- | src/vcli.c | 8 |
4 files changed, 52 insertions, 16 deletions
@@ -66,4 +66,4 @@ 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) { @@ -78,3 +78,3 @@ varnish_ban_table_timeout_parser(const char *token, char *line) config_perror("too many arguments"); - return; + return 1; } @@ -82,3 +82,3 @@ varnish_ban_table_timeout_parser(const char *token, char *line) config_perror("invalid timeout value"); - return; + return 1; } @@ -88,6 +88,13 @@ varnish_ban_table_timeout_parser(const char *token, char *line) 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); } @@ -102,3 +109,3 @@ varnish_ban_table_timeout_set(netsnmp_agent_request_info *reqinfo, return SNMP_ERR_BADVALUE; - DEBUGMSGTL(("varnish_ban", "setting banTable timeould %ld\n", + DEBUGMSGTL(("varnish_ban", "setting banTable timeout %ld\n", *requests->requestvb->val.integer)); 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 @@ -15,9 +15,9 @@ .\" 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 @@ -30,2 +30,10 @@ 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 @@ -38,2 +46,4 @@ file below the statement that loads the module. +.PP +The following configuration statements are available: .TP @@ -49,2 +59,6 @@ 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 @@ -77,3 +91,3 @@ 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 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 @@ -168,4 +168,8 @@ int varnish_ban(netsnmp_agent_request_info *reqinfo, +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); @@ -174,3 +178,2 @@ int varnish_ban_table_timeout_set(netsnmp_agent_request_info *reqinfo, struct VSM_data *vd); -int varnish_ban_table_timeout_get(void **valptr, size_t *valsize); @@ -316,3 +319,3 @@ handle_$i(netsnmp_mib_handler *handler, # RESERVE2. Something failed somewhere, and the states - # below won't be called. */ + # below won't be called. $varnish_set_free(reqinfo, requests, vd); @@ -529,3 +532,9 @@ init_$modulename(void) 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@ @@ -29,3 +29,9 @@ -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); +} |