diff options
author | Sergey Poznyakoff <gray@nxc.no> | 2018-02-02 14:50:53 +0100 |
---|---|---|
committer | Sergey Poznyakoff <gray@nxc.no> | 2018-02-02 14:50:53 +0100 |
commit | 8a2e9da972cee4714c02f3dd23a3b7fcab9a0476 (patch) | |
tree | ee00ab302734161ec756313e8bbede8a82fb86eb /src | |
parent | 83919b99e222077a1bb61757403779cc4f456edc (diff) | |
download | varnish-mib-8a2e9da972cee4714c02f3dd23a3b7fcab9a0476.tar.gz varnish-mib-8a2e9da972cee4714c02f3dd23a3b7fcab9a0476.tar.bz2 |
Bugfixes
Use consistend debug token names. Make sure configuration settings are
honored by opening VSM and doing initial loading after the configuration
has been read and processed. Avoid inifinite recursion in dict_load.
* src/modconf.c: New file.
* src/modconf.h: New file.
* src/vclient.h: New file.
* src/Makefile.am: Add new files.
* src/VARNISH-MIB.txt: Minor changes in descriptions.
* src/backend.h (backend_collect_addr): Change prototype.
* src/ban.c: Remove configuration management functions.
* src/betab.c: Likewise.
* src/statdict.c (dict_lookup): Remove debugging kludge.
(dict_load): Don't call backend_collect_addr. It is responsibility
of the caller.
* src/varnish_mib.mib2c: Rearrange includes. Open VSM after
parsing configuration.
(init_$modulename): Allow loading of one instance only.
* src/vcli.c: Rewrite socket support.
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 5 | ||||
-rw-r--r-- | src/VARNISH-MIB.txt | 16 | ||||
-rw-r--r-- | src/backend.h | 2 | ||||
-rw-r--r-- | src/ban.c | 45 | ||||
-rw-r--r-- | src/betab.c | 20 | ||||
-rw-r--r-- | src/modconf.c | 123 | ||||
-rw-r--r-- | src/modconf.h | 9 | ||||
-rw-r--r-- | src/statdict.c | 4 | ||||
-rw-r--r-- | src/varnish_mib.mib2c | 86 | ||||
-rw-r--r-- | src/vcli.c | 196 | ||||
-rw-r--r-- | src/vclient.h | 21 |
11 files changed, 340 insertions, 187 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 3b5547b..3ef9fa5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am | |||
@@ -23,12 +23,15 @@ varnish_mib_la_SOURCES = \ | |||
23 | backend.h\ | 23 | backend.h\ |
24 | belex.l\ | 24 | belex.l\ |
25 | betab.c\ | 25 | betab.c\ |
26 | modconf.h\ | ||
27 | modconf.c\ | ||
26 | sha256.c\ | 28 | sha256.c\ |
27 | sha256.h\ | 29 | sha256.h\ |
28 | statdict.c\ | 30 | statdict.c\ |
29 | varnish_mib.c\ | 31 | varnish_mib.c\ |
30 | varnish_mib.h\ | 32 | varnish_mib.h\ |
31 | vcli.c | 33 | vcli.c\ |
34 | vclient.h | ||
32 | 35 | ||
33 | BUILT_SOURCES = \ | 36 | BUILT_SOURCES = \ |
34 | varnish_mib.c\ | 37 | varnish_mib.c\ |
diff --git a/src/VARNISH-MIB.txt b/src/VARNISH-MIB.txt index 8d60477..6b03f21 100644 --- a/src/VARNISH-MIB.txt +++ b/src/VARNISH-MIB.txt | |||
@@ -20,14 +20,14 @@ IMPORTS | |||
20 | FROM SNMPv2-CONF; | 20 | FROM SNMPv2-CONF; |
21 | 21 | ||
22 | varnishMIB MODULE-IDENTITY | 22 | varnishMIB MODULE-IDENTITY |
23 | LAST-UPDATED "201802012132Z" | 23 | LAST-UPDATED "201802020845Z" |
24 | ORGANIZATION "Shared Autonomous sYstems" | 24 | ORGANIZATION "Shared Autonomous sYstems" |
25 | CONTACT-INFO "Morten Hermanrud <mhe@say.no> | 25 | CONTACT-INFO "Morten Hermanrud <mhe@say.no> |
26 | Sergey Poznyakoff <gray@gnu.org> | 26 | Sergey Poznyakoff <gray@gnu.org> |
27 | " | 27 | " |
28 | DESCRIPTION | 28 | DESCRIPTION |
29 | "This MIB module defines objects for Varnish reverse web proxy." | 29 | "This MIB module defines objects for Varnish reverse web proxy." |
30 | REVISION "201802012132Z" | 30 | REVISION "201802020845Z" |
31 | DESCRIPTION | 31 | DESCRIPTION |
32 | "Second revision." | 32 | "Second revision." |
33 | ::= { varnish 0 } | 33 | ::= { varnish 0 } |
@@ -112,7 +112,8 @@ clientRequests411 OBJECT-TYPE | |||
112 | MAX-ACCESS read-only | 112 | MAX-ACCESS read-only |
113 | STATUS current | 113 | STATUS current |
114 | DESCRIPTION | 114 | DESCRIPTION |
115 | "Client requests received, subject to 411 errors." | 115 | "Client requests received, subject to 411 errors. |
116 | This OID is not available in Varnish version 5 and above." | ||
116 | ::= { client 8 } | 117 | ::= { client 8 } |
117 | 118 | ||
118 | clientRequests413 OBJECT-TYPE | 119 | clientRequests413 OBJECT-TYPE |
@@ -120,7 +121,8 @@ clientRequests413 OBJECT-TYPE | |||
120 | MAX-ACCESS read-only | 121 | MAX-ACCESS read-only |
121 | STATUS current | 122 | STATUS current |
122 | DESCRIPTION | 123 | DESCRIPTION |
123 | "Client requests received, subject to 413 errors." | 124 | "Client requests received, subject to 413 errors. |
125 | This OID is not available in Varnish version 5 and above." | ||
124 | ::= { client 9 } | 126 | ::= { client 9 } |
125 | 127 | ||
126 | clientRequests417 OBJECT-TYPE | 128 | clientRequests417 OBJECT-TYPE |
@@ -186,7 +188,8 @@ backendConnUnused OBJECT-TYPE | |||
186 | MAX-ACCESS read-only | 188 | MAX-ACCESS read-only |
187 | STATUS current | 189 | STATUS current |
188 | DESCRIPTION | 190 | DESCRIPTION |
189 | "Backend connections unused." | 191 | "Backend connections unused. |
192 | This OID is not available in Varnish version 5 and above." | ||
190 | ::= { connections 7 } | 193 | ::= { connections 7 } |
191 | 194 | ||
192 | backendConnRetry OBJECT-TYPE | 195 | backendConnRetry OBJECT-TYPE |
@@ -912,7 +915,8 @@ vclFail OBJECT-TYPE | |||
912 | MAX-ACCESS read-only | 915 | MAX-ACCESS read-only |
913 | STATUS current | 916 | STATUS current |
914 | DESCRIPTION | 917 | DESCRIPTION |
915 | "Number of VCL failures" | 918 | "Number of VCL failures. |
919 | This OID is not available in Varnish 4 and below." | ||
916 | ::= { vcl 4 } | 920 | ::= { vcl 4 } |
917 | 921 | ||
918 | -- | 922 | -- |
diff --git a/src/backend.h b/src/backend.h index 0c15e60..d60f613 100644 --- a/src/backend.h +++ b/src/backend.h | |||
@@ -11,6 +11,6 @@ struct VSC_point; | |||
11 | void backend_register(char const *name, size_t len, char const *param, | 11 | void backend_register(char const *name, size_t len, char const *param, |
12 | const struct VSC_point *vpt); | 12 | const struct VSC_point *vpt); |
13 | void backend_clear(void); | 13 | void backend_clear(void); |
14 | int backend_collect_addr(void); | 14 | int backend_collect_addr(struct vsm *vsm); |
15 | void backend_parser(const char *str, size_t len, regfun_t regfun, void *d); | 15 | void backend_parser(const char *str, size_t len, regfun_t regfun, void *d); |
16 | 16 | ||
@@ -51,7 +51,7 @@ varnish_ban(netsnmp_agent_request_info *reqinfo, | |||
51 | } | 51 | } |
52 | memcpy(expr, requests->requestvb->val.string, len); | 52 | memcpy(expr, requests->requestvb->val.string, len); |
53 | expr[len] = 0; | 53 | expr[len] = 0; |
54 | DEBUGMSGTL(("varnish_ban", "setting ban %s\n", expr)); | 54 | DEBUGMSGTL(("varnish_mib:ban", "setting ban %s\n", expr)); |
55 | rc = vcli_connect(vsm, &conn); | 55 | rc = vcli_connect(vsm, &conn); |
56 | if (rc == SNMP_ERR_NOERROR) { | 56 | if (rc == SNMP_ERR_NOERROR) { |
57 | rc = send_ban_cmd(&conn, expr); | 57 | rc = send_ban_cmd(&conn, expr); |
@@ -61,43 +61,6 @@ varnish_ban(netsnmp_agent_request_info *reqinfo, | |||
61 | return rc ? SNMP_ERR_GENERR : SNMP_ERR_NOERROR; | 61 | return rc ? SNMP_ERR_GENERR : SNMP_ERR_NOERROR; |
62 | } | 62 | } |
63 | 63 | ||
64 | unsigned banTable_timeout = 60; | ||
65 | |||
66 | int | ||
67 | varnish_mib_timeout_parser(const char *token, char *line, unsigned *retval) | ||
68 | { | ||
69 | char *p; | ||
70 | unsigned long n = strtoul(line, &p, 10); | ||
71 | |||
72 | if (*p) { | ||
73 | if (isspace(*p)) { | ||
74 | while (*p && isspace(*p)) | ||
75 | ++p; | ||
76 | if (*p) { | ||
77 | config_perror("too many arguments"); | ||
78 | return 1; | ||
79 | } | ||
80 | } else { | ||
81 | config_perror("invalid timeout value"); | ||
82 | return 1; | ||
83 | } | ||
84 | } | ||
85 | |||
86 | if (n > UINT_MAX) { | ||
87 | config_perror("timeout value out of allowed range"); | ||
88 | return 1; | ||
89 | } | ||
90 | |||
91 | *retval = n; | ||
92 | return 0; | ||
93 | } | ||
94 | |||
95 | void | ||
96 | varnish_ban_table_timeout_parser(const char *token, char *line) | ||
97 | { | ||
98 | varnish_mib_timeout_parser(token, line, &banTable_timeout); | ||
99 | } | ||
100 | |||
101 | /* | 64 | /* |
102 | * create a new row in the table | 65 | * create a new row in the table |
103 | */ | 66 | */ |
@@ -156,7 +119,7 @@ banTable_load(netsnmp_cache *cache, void *vmagic) | |||
156 | if (!vsm) | 119 | if (!vsm) |
157 | return SNMP_ERR_GENERR; | 120 | return SNMP_ERR_GENERR; |
158 | 121 | ||
159 | DEBUGMSGTL(("varnish_ban", "reloading ban table\n")); | 122 | DEBUGMSGTL(("varnish_mib:ban", "reloading ban table\n")); |
160 | rc = vcli_connect(vsm, &conn); | 123 | rc = vcli_connect(vsm, &conn); |
161 | 124 | ||
162 | if (rc != SNMP_ERR_NOERROR) | 125 | if (rc != SNMP_ERR_NOERROR) |
@@ -266,7 +229,7 @@ banTable_load(netsnmp_cache *cache, void *vmagic) | |||
266 | p = q; | 229 | p = q; |
267 | } | 230 | } |
268 | vcli_disconnect(&conn); | 231 | vcli_disconnect(&conn); |
269 | DEBUGMSGTL(("varnish_ban", "loaded %ld ban entries\n", idx)); | 232 | DEBUGMSGTL(("varnish_mib:ban", "loaded %ld ban entries\n", idx)); |
270 | return 0; | 233 | return 0; |
271 | } | 234 | } |
272 | 235 | ||
@@ -276,7 +239,7 @@ banTable_free(netsnmp_cache *cache, void *vmagic) | |||
276 | netsnmp_tdata *table = (netsnmp_tdata *) vmagic; | 239 | netsnmp_tdata *table = (netsnmp_tdata *) vmagic; |
277 | netsnmp_tdata_row *row; | 240 | netsnmp_tdata_row *row; |
278 | 241 | ||
279 | DEBUGMSGTL(("varnish_ban", "freeing ban table\n")); | 242 | DEBUGMSGTL(("varnish_mib:ban", "freeing ban table\n")); |
280 | while ((row = netsnmp_tdata_row_first(table))) { | 243 | while ((row = netsnmp_tdata_row_first(table))) { |
281 | struct banTable_entry *entry = row->data; | 244 | struct banTable_entry *entry = row->data; |
282 | free(entry->banExpression); | 245 | free(entry->banExpression); |
diff --git a/src/betab.c b/src/betab.c index 388083b..afec48a 100644 --- a/src/betab.c +++ b/src/betab.c | |||
@@ -136,7 +136,7 @@ backendTable_load(netsnmp_cache *cache, void *vmagic) | |||
136 | netsnmp_tdata *table_data = (netsnmp_tdata *) vmagic; | 136 | netsnmp_tdata *table_data = (netsnmp_tdata *) vmagic; |
137 | struct backend_dfn *dfn; | 137 | struct backend_dfn *dfn; |
138 | 138 | ||
139 | DEBUGMSGTL(("varnish_backend", "loading backend table\n")); | 139 | DEBUGMSGTL(("varnish_mib:backend", "loading backend table\n")); |
140 | 140 | ||
141 | VTAILQ_FOREACH(dfn, &backends, list) { | 141 | VTAILQ_FOREACH(dfn, &backends, list) { |
142 | int i; | 142 | int i; |
@@ -182,7 +182,7 @@ backendTable_free(netsnmp_cache *cache, void *vmagic) | |||
182 | net |