aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2019-02-14 12:07:17 +0200
committerSergey Poznyakoff <gray@gnu.org>2019-02-14 12:07:17 +0200
commitfe4dd5c7fe77591ee8d7780d3f5e2e9b9334c2c5 (patch)
treeba465cbde75e7f2e7dd5216246713bf6003a1bfd /src
parent45c6086f8c0c0f6fe1a46b950682abfdbf104687 (diff)
downloadvarnish-mib-fe4dd5c7fe77591ee8d7780d3f5e2e9b9334c2c5.tar.gz
varnish-mib-fe4dd5c7fe77591ee8d7780d3f5e2e9b9334c2c5.tar.bz2
Minor changes
Diffstat (limited to 'src')
-rw-r--r--src/ban.c10
-rw-r--r--src/betab.c8
-rw-r--r--src/main.c6
-rw-r--r--src/varnish-mib.88
-rw-r--r--src/vcli.c16
5 files changed, 23 insertions, 25 deletions
diff --git a/src/ban.c b/src/ban.c
index a50b5a3..02ae979 100644
--- a/src/ban.c
+++ b/src/ban.c
@@ -1,5 +1,5 @@
1/* This file is part of varnish-mib -*- c -*- 1/* This file is part of varnish-mib -*- c -*-
2 Copyright (C) 2014-2018 Sergey Poznyakoff 2 Copyright (C) 2014-2019 Sergey Poznyakoff
3 3
4 Varnish-mib is free software; you can redistribute it and/or modify 4 Varnish-mib is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
@@ -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_mib:ban", "setting ban %s\n", expr)); 54 DEBUGMSGTL(("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);
@@ -119,7 +119,7 @@ banTable_load(netsnmp_cache *cache, void *vmagic)
119 if (!vsm) 119 if (!vsm)
120 return SNMP_ERR_GENERR; 120 return SNMP_ERR_GENERR;
121 121
122 DEBUGMSGTL(("varnish_mib:ban", "reloading ban table\n")); 122 DEBUGMSGTL(("ban", "reloading ban table\n"));
123 rc = vcli_connect(vsm, &conn); 123 rc = vcli_connect(vsm, &conn);
124 124
125 if (rc != SNMP_ERR_NOERROR) 125 if (rc != SNMP_ERR_NOERROR)
@@ -229,7 +229,7 @@ banTable_load(netsnmp_cache *cache, void *vmagic)
229 p = q; 229 p = q;
230 } 230 }
231 vcli_disconnect(&conn); 231 vcli_disconnect(&conn);
232 DEBUGMSGTL(("varnish_mib:ban", "loaded %ld ban entries\n", idx)); 232 DEBUGMSGTL(("ban", "loaded %ld ban entries\n", idx));
233 return 0; 233 return 0;
234} 234}
235 235
@@ -239,7 +239,7 @@ banTable_free(netsnmp_cache *cache, void *vmagic)
239 netsnmp_tdata *table = (netsnmp_tdata *) vmagic; 239 netsnmp_tdata *table = (netsnmp_tdata *) vmagic;
240 netsnmp_tdata_row *row; 240 netsnmp_tdata_row *row;
241 241
242 DEBUGMSGTL(("varnish_mib:ban", "freeing ban table\n")); 242 DEBUGMSGTL(("ban", "freeing ban table\n"));
243 while ((row = netsnmp_tdata_row_first(table))) { 243 while ((row = netsnmp_tdata_row_first(table))) {
244 struct banTable_entry *entry = row->data; 244 struct banTable_entry *entry = row->data;
245 free(entry->banExpression); 245 free(entry->banExpression);
diff --git a/src/betab.c b/src/betab.c
index 768503a..c472b9d 100644
--- a/src/betab.c
+++ b/src/betab.c
@@ -1,5 +1,5 @@
1/* This file is part of varnish-mib 1/* This file is part of varnish-mib
2 Copyright (C) 2014, 2018 Sergey Poznyakoff 2 Copyright (C) 2014-2019 Sergey Poznyakoff
3 3
4 Varnish-mib is free software; you can redistribute it and/or modify 4 Varnish-mib is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
@@ -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_mib:backend", "loading backend table\n")); 139 DEBUGMSGTL(("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 netsnmp_tdata *table = (netsnmp_tdata *) vmagic; 182 netsnmp_tdata *table = (netsnmp_tdata *) vmagic;
183 netsnmp_tdata_row *row; 183 netsnmp_tdata_row *row;
184 184
185 DEBUGMSGTL(("varnish_mib:backend", "freeing backend table\n")); 185 DEBUGMSGTL(("backend", "freeing backend table\n"));
186 while ((row = netsnmp_tdata_row_first(table))) { 186 while ((row = netsnmp_tdata_row_first(table))) {
187 struct backendTable_entry *entry = row->data; 187 struct backendTable_entry *entry = row->data;
188 free(entry->vbeIdent); 188 free(entry->vbeIdent);
@@ -334,7 +334,7 @@ backend_collect_addr(struct vsm *vsm)
334 struct backend_name_list namelist 334 struct backend_name_list namelist
335 = VTAILQ_HEAD_INITIALIZER(namelist); 335 = VTAILQ_HEAD_INITIALIZER(namelist);
336 336
337 DEBUGMSGTL(("varnish_mib:backend", "getting backend info\n")); 337 DEBUGMSGTL(("backend", "getting backend info\n"));
338 338
339 rc = vcli_connect(vsm, &conn); 339 rc = vcli_connect(vsm, &conn);
340 if (rc != SNMP_ERR_NOERROR) 340 if (rc != SNMP_ERR_NOERROR)
diff --git a/src/main.c b/src/main.c
index a8d089f..01a24a9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -161,6 +161,9 @@ main(int argc, char **argv)
161 161
162 netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, 162 netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID,
163 NETSNMP_DS_AGENT_ROLE, 1); 163 NETSNMP_DS_AGENT_ROLE, 1);
164 if (!log_set)
165 snmp_enable_stderrlog();
166
164 SOCK_STARTUP; 167 SOCK_STARTUP;
165 init_agent(progname); 168 init_agent(progname);
166 init_varnish_mib(); 169 init_varnish_mib();
@@ -182,9 +185,6 @@ main(int argc, char **argv)
182 snmp_enable_syslog_ident(progname, LOG_DAEMON); 185 snmp_enable_syslog_ident(progname, LOG_DAEMON);
183 snmp_disable_stderrlog(); 186 snmp_disable_stderrlog();
184 } 187 }
185 } else {
186 if (!log_set)
187 snmp_enable_stderrlog();
188 } 188 }
189 189
190 pidfile_create(pid_file); 190 pidfile_create(pid_file);
diff --git a/src/varnish-mib.8 b/src/varnish-mib.8
index 0856c69..3dc28d8 100644
--- a/src/varnish-mib.8
+++ b/src/varnish-mib.8
@@ -120,18 +120,18 @@ are:
120.B varnish_mib 120.B varnish_mib
121Produces general debugging information. 121Produces general debugging information.
122.TP 122.TP
123.B varnish_mib:ban 123.B ban
124Outputs verbose report about loading th ban table. 124Outputs verbose report about loading th ban table.
125.TP 125.TP
126.B varnish_mib:vcli 126.B vcli
127Displays additional information regarding varnish 127Displays additional information regarding varnish
128.B CLI 128.B CLI
129interaction. 129interaction.
130.TP 130.TP
131.B varnish_mib:vcli:transcript 131.B vcli:transcript
132Enables full transcript of varnish CLI session. 132Enables full transcript of varnish CLI session.
133.TP 133.TP
134.B varnish_mib:backend 134.B backend
135Outputs verbose information about loading the backend information. 135Outputs verbose information about loading the backend information.
136.RE 136.RE
137.TP 137.TP
diff --git a/src/vcli.c b/src/vcli.c
index 94f0eef..8669446 100644
--- a/src/vcli.c
+++ b/src/vcli.c
@@ -1,5 +1,5 @@
1/* This file is part of varnish-mib -*- c -*- 1/* This file is part of varnish-mib -*- c -*-
2 Copyright (C) 2014-2018 Sergey Poznyakoff 2 Copyright (C) 2014-2019 Sergey Poznyakoff
3 3
4 Varnish-mib is free software; you can redistribute it and/or modify 4 Varnish-mib is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
@@ -199,7 +199,7 @@ vcli_read(struct vcli_conn *conn, size_t size)
199 if (conn->bufsize == 0) 199 if (conn->bufsize == 0)
200 ret = -1; 200 ret = -1;
201 conn->base[conn->bufsize] = 0; 201 conn->base[conn->bufsize] = 0;
202 DEBUGMSGTL(("varnish_mib:vcli:transcript", "<<varnish: %s\n", conn->base)); 202 DEBUGMSGTL(("vcli:transcript", "<<varnish: %s\n", conn->base));
203 } 203 }
204 204
205 return ret; 205 return ret;
@@ -282,7 +282,7 @@ vcli_write(struct vcli_conn *conn)
282{ 282{
283 size_t size; 283 size_t size;
284 284
285 DEBUGMSGTL(("varnish_mib:vcli:transcript", ">>varnish: %s\n", conn->base)); 285 DEBUGMSGTL(("vcli:transcript", ">>varnish: %s\n", conn->base));
286 for (size = 0; size < conn->bufsize; ) { 286 for (size = 0; size < conn->bufsize; ) {
287 int n = write(conn->fd, conn->base + size, 287 int n = write(conn->fd, conn->base + size,
288 conn->bufsize - size); 288 conn->bufsize - size);
@@ -490,8 +490,7 @@ static int
490parse_connection(struct vsm *vsm, vcli_sockaddr_t *addr, char **secret) 490parse_connection(struct vsm *vsm, vcli_sockaddr_t *addr, char **secret)
491{ 491{
492 if (vcli_sockaddr) { 492 if (vcli_sockaddr) {
493 DEBUGMSGTL(("varnish_mib:vcli", 493 DEBUGMSGTL(("vcli", "using configured sockaddr\n"));
494 "using configured sockaddr\n"));
495 *addr = vcli_sockaddr_dup(vcli_sockaddr); 494 *addr = vcli_sockaddr_dup(vcli_sockaddr);
496 } else { 495 } else {
497 char *T_arg, *p; 496 char *T_arg, *p;
@@ -503,7 +502,7 @@ parse_connection(struct vsm *vsm, vcli_sockaddr_t *addr, char **secret)
503 p = T_arg + strlen(T_arg) - 1; 502 p = T_arg + strlen(T_arg) - 1;
504 if (*p == '\n') 503 if (*p == '\n')
505 *p = 0; 504 *p = 0;
506 DEBUGMSGTL(("varnish_mib:vcli", "-T '%s'\n", T_arg)); 505 DEBUGMSGTL(("vcli", "-T '%s'\n", T_arg));
507 *addr = vcli_parse_sockaddr(T_arg); 506 *addr = vcli_parse_sockaddr(T_arg);
508 free(T_arg); 507 free(T_arg);
509 } 508 }
@@ -511,8 +510,7 @@ parse_connection(struct vsm *vsm, vcli_sockaddr_t *addr, char **secret)
511 return SNMP_ERR_GENERR; 510 return SNMP_ERR_GENERR;
512 511
513 if (vcli_secret) { 512 if (vcli_secret) {
514 DEBUGMSGTL(("varnish_mib:vcli", 513 DEBUGMSGTL(("vcli", "using configured secret\n"));
515 "using configured secret\n"));
516 *secret = strdup(vcli_secret); 514 *secret = strdup(vcli_secret);
517 if (!*secret) { 515 if (!*secret) {
518 snmp_log(LOG_ERR, "out of memory"); 516 snmp_log(LOG_ERR, "out of memory");
@@ -524,7 +522,7 @@ parse_connection(struct vsm *vsm, vcli_sockaddr_t *addr, char **secret)