Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnishevent
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
varnishevent
Commits
e0e3eb7d
Commit
e0e3eb7d
authored
Oct 04, 2018
by
Nils Goroll
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into new_output_buffering
parents
b70c9d10
21e14e69
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
97 additions
and
32 deletions
+97
-32
README.rst
README.rst
+6
-0
config.c
src/config.c
+51
-28
test_data.c
src/test/test_data.c
+1
-0
test_format.c
src/test/test_format.c
+1
-0
varnishevent.conf
src/test/varnishevent.conf
+35
-2
varnishevent.c
src/varnishevent.c
+2
-1
varnishevent.h
src/varnishevent.h
+1
-1
No files found.
README.rst
View file @
e0e3eb7d
...
...
@@ -450,12 +450,18 @@ The syntax of a configuration file is simply::
# comment
<param> = <value>
<param> += <value>
The ``<value>`` is all of the data from the first non-whitespace
character after the equals sign up to the last non-whitespace
character on the line. Comments begin with the hash character and
extend to the end of the line. There are no continuation lines.
The ``=`` operator assigns, ``+=`` appends to a previous value with a
single space character inbetween the previous and appended
value. ``+=`` is only supported for parameters ``cformat``,
``bformat``, ``rformat`` and ``syslog.ident``.
All of the config parameters have default values, and some of them
correspond to command-line options, as shown below.
...
...
src/config.c
View file @
e0e3eb7d
...
...
@@ -107,14 +107,22 @@ conf_getDouble(const char *rval, double *d)
return(0); \
}
#define confVSB(name,fld
)
\
#define confVSB(name,fld
, op)
\
if (strcmp(lval, (name)) == 0) { \
VSB_clear(config.fld); \
if (strcmp(op, "=") == 0) \
VSB_clear(config.fld); \
else if (strcmp(op, "+=") == 0) \
VSB_cat(config.fld, " "); \
else \
INCOMPL(); \
VSB_cat(config.fld, rval); \
VSB_finish(config.fld); \
return(0); \
}
#define finiVSB(fld) \
VSB_finish(config.fld)
/* XXX: need confNonNegative? */
#define confUnsigned(name,fld) \
...
...
@@ -137,20 +145,23 @@ conf_getDouble(const char *rval, double *d)
return(0); \
}
int
CONF_Add
(
const
char
*
lval
,
const
char
*
rval
)
static
int
conf_Add
(
const
char
*
lval
,
const
char
*
op
,
const
char
*
rval
)
{
int
ret
;
confVSB
(
"cformat"
,
cformat
,
op
);
confVSB
(
"bformat"
,
bformat
,
op
);
confVSB
(
"rformat"
,
rformat
,
op
);
confVSB
(
"syslog.ident"
,
syslog_ident
,
op
);
if
(
strcmp
(
op
,
"="
))
return
ENOTSUP
;
confString
(
"log.file"
,
log_file
);
confString
(
"output.file"
,
output_file
);
confString
(
"varnish.bindump"
,
varnish_bindump
);
confVSB
(
"cformat"
,
cformat
);
confVSB
(
"bformat"
,
bformat
);
confVSB
(
"rformat"
,
rformat
);
confVSB
(
"syslog.ident"
,
syslog_ident
);
confUnsigned
(
"max.reclen"
,
max_reclen
);
confUnsigned
(
"chunk_size"
,
chunk_size
);
confUnsigned
(
"max.data"
,
max_data
);
...
...
@@ -175,24 +186,30 @@ CONF_Add(const char *lval, const char *rval)
}
static
int
conf_ParseLine
(
char
*
ptr
,
char
**
lval
,
char
**
rval
)
conf_ParseLine
(
char
*
ptr
,
char
**
lval
,
char
**
op
,
char
**
rval
)
{
char
*
endlval
;
*
lval
=
ptr
;
while
(
*++
ptr
&&
!
isspace
(
*
ptr
)
&&
*
ptr
!=
'='
)
while
(
*++
ptr
&&
!
isspace
(
*
ptr
)
&&
*
ptr
!=
'='
&&
*
ptr
!=
'+'
)
;
if
(
*
ptr
==
'\0'
)
return
(
1
);
endlval
=
ptr
;
while
(
isspace
(
*
ptr
)
&&
*++
ptr
)
;
if
(
ptr
==
'\0'
||
*
ptr
!=
'='
)
return
(
1
);
while
(
*++
ptr
&&
isspace
(
*
ptr
))
;
if
(
ptr
==
'\0'
)
while
(
isspace
(
*
ptr
))
ptr
++
;
if
(
*
ptr
==
'+'
&&
ptr
[
1
]
==
'='
)
{
*
op
=
"+="
;
ptr
+=
2
;
}
else
if
(
*
ptr
==
'='
)
{
*
op
=
"="
;
ptr
++
;
}
else
return
(
1
);
while
(
isspace
(
*
ptr
))
ptr
++
;
*
endlval
=
'\0'
;
*
rval
=
ptr
;
return
(
0
);
...
...
@@ -209,14 +226,10 @@ CONF_Init(void)
config
.
cformat
=
VSB_new_auto
();
VSB_cat
(
config
.
cformat
,
DEFAULT_CFORMAT
);
VSB_finish
(
config
.
cformat
);
config
.
bformat
=
VSB_new_auto
();
VSB_finish
(
config
.
bformat
);
config
.
rformat
=
VSB_new_auto
();
VSB_finish
(
config
.
rformat
);
config
.
syslog_ident
=
VSB_new_auto
();
VSB_cat
(
config
.
syslog_ident
,
"varnishevent"
);
VSB_finish
(
config
.
syslog_ident
);
config
.
syslog_facility
=
LOG_LOCAL0
;
...
...
@@ -232,6 +245,15 @@ CONF_Init(void)
config
.
reader_timeout
=
0
.;
}
void
CONF_Fini
(
void
)
{
finiVSB
(
cformat
);
finiVSB
(
bformat
);
finiVSB
(
rformat
);
finiVSB
(
syslog_ident
);
}
static
int
conf_get_line
(
char
*
line
,
FILE
*
in
)
{
...
...
@@ -285,20 +307,21 @@ CONF_ReadFile(const char *file) {
VSB_cat
(
orig
,
ptr
);
VSB_finish
(
orig
);
char
*
lval
,
*
rval
;
if
(
conf_ParseLine
(
ptr
,
&
lval
,
&
rval
)
!=
0
)
{
char
*
lval
,
*
op
,
*
rval
;
if
(
conf_ParseLine
(
ptr
,
&
lval
,
&
op
,
&
rval
)
!=
0
)
{
fprintf
(
stderr
,
"Cannot parse %s line %d: '%s'
\n
"
,
file
,
linenum
,
VSB_data
(
orig
));
return
(
-
1
);
}
int
ret
;
if
((
ret
=
CONF_Add
((
const
char
*
)
lval
,
(
const
char
*
)
rval
))
!=
0
)
{
if
((
ret
=
conf_Add
(
lval
,
op
,
rval
))
!=
0
)
{
fprintf
(
stderr
,
"Error in %s line %d (%s): '%s'
\n
"
,
file
,
linenum
,
strerror
(
ret
),
VSB_data
(
orig
));
return
(
-
1
);
}
}
int
ret
=
0
;
if
(
ferror
(
in
))
{
fprintf
(
stderr
,
"Error reading file %s (errno %d: %s)
\n
"
,
file
,
errno
,
...
...
src/test/test_data.c
View file @
e0e3eb7d
...
...
@@ -64,6 +64,7 @@ static char
MAZ
(
LOG_Open
(
"test_data"
));
CONF_Init
();
CONF_Fini
();
MAZ
(
FMT_Init
(
fmterr
));
VMASSERT
((
err
=
DATA_Init
())
==
0
,
"DATA_Init: %s"
,
strerror
(
err
));
...
...
src/test/test_format.c
View file @
e0e3eb7d
...
...
@@ -216,6 +216,7 @@ static const char
printf
(
"... initializing format tests
\n
"
);
CONF_Init
();
CONF_Fini
();
status
=
FMT_Init
(
err
);
VMASSERT
(
status
==
0
,
"FMT_Init: %s"
,
err
);
...
...
src/test/varnishevent.conf
View file @
e0e3eb7d
...
...
@@ -2,8 +2,41 @@
monitor
.
interval
=
0
cformat
=%
b
%
d
%
D
%
H
%
h
%
I
%{
Host
}
i
%{
Connection
}
i
%{
User
-
Agent
}
i
%{
X
-
Forwarded
-
For
}
i
%{
Accept
-
Ranges
}
o
%{
Age
}
o
%{
Connection
}
o
%{
Content
-
Encoding
}
o
%{
Content
-
Length
}
o
%{
Content
-
Type
}
o
%{
Date
}
o
%{
Last
-
Modified
}
o
%{
Server
}
o
%{
Transfer
-
Encoding
}
o
%{
Via
}
o
%{
X
-
Varnish
}
o
%
l
%
m
%
O
%
q
%
r
%
s
%
t
%{%
F
-%
T
}
t
%
U
%
u
%{
Varnish
:
time_firstbyte
}
x
%{
Varnish
:
hitmiss
}
x
%{
Varnish
:
handling
}
x
%{
tag
:
Begin
}
x
%{
tag
:
Debug
}
x
%{
tag
:
End
}
x
%{
tag
:
Gzip
}
x
%{
tag
:
Hit
}
x
%{
tag
:
Length
}
x
%{
tag
:
Link
}
x
%{
tag
:
ReqAcct
}
x
%{
tag
:
ReqStart
}
x
%{
tag
:
RespProtocol
}
x
%{
tag
:
ReqMethod
}
x
%{
tag
:
ReqURL
}
x
%{
tag
:
ReqProtocol
}
x
%{
tag
:
RespReason
}
x
%{
tag
:
RespStatus
}
x
%{
tag
:
Timestamp
:
Req
}
x
%{
tag
:
ReqAcct
[
5
]}
x
%{
tag
:
Timestamp
:
Req
[
2
]}
x
%{
VSL
:
Begin
}
x
%{
VSL
:
Debug
}
x
%{
VSL
:
End
}
x
%{
VSL
:
Gzip
}
x
%{
VSL
:
Hit
}
x
%{
VSL
:
Length
}
x
%{
VSL
:
Link
}
x
%{
VSL
:
ReqAcct
}
x
%{
VSL
:
ReqStart
}
x
%{
VSL
:
RespProtocol
}
x
%{
VSL
:
ReqMethod
}
x
%{
VSL
:
ReqURL
}
x
%{
VSL
:
ReqProtocol
}
x
%{
VSL
:
RespReason
}
x
%{
VSL
:
RespStatus
}
x
%{
VSL
:
Timestamp
:
Req
}
x
%{
VSL
:
ReqAcct
[
5
]}
x
%{
VSL
:
Timestamp
:
Req
[
2
]}
x
%{
VSL
:
Timestamp
}
x
%{
vxid
}
x
%{
Varnish
:
vxid
}
x
%{
pvxid
}
x
%{
Varnish
:
side
}
x
cformat
=%
b
%
d
%
D
%
H
%
h
%
I
%{
Host
}
i
%{
Connection
}
i
%{
User
-
Agent
}
i
cformat
+=%{
X
-
Forwarded
-
For
}
i
%{
Accept
-
Ranges
}
o
%{
Age
}
o
%{
Connection
}
o
cformat
+=%{
Content
-
Encoding
}
o
%{
Content
-
Length
}
o
%{
Content
-
Type
}
o
%{
Date
}
o
cformat
+=%{
Last
-
Modified
}
o
%{
Server
}
o
%{
Transfer
-
Encoding
}
o
%{
Via
}
o
cformat
+=%{
X
-
Varnish
}
o
%
l
%
m
%
O
%
q
%
r
%
s
%
t
%{%
F
-%
T
}
t
%
U
%
u
cformat
+=%{
Varnish
:
time_firstbyte
}
x
%{
Varnish
:
hitmiss
}
x
%{
Varnish
:
handling
}
x
cformat
+=%{
tag
:
Begin
}
x
%{
tag
:
Debug
}
x
%{
tag
:
End
}
x
%{
tag
:
Gzip
}
x
%{
tag
:
Hit
}
x
cformat
+=%{
tag
:
Length
}
x
%{
tag
:
Link
}
x
%{
tag
:
ReqAcct
}
x
%{
tag
:
ReqStart
}
x
cformat
+=%{
tag
:
RespProtocol
}
x
%{
tag
:
ReqMethod
}
x
%{
tag
:
ReqURL
}
x
cformat
+=%{
tag
:
ReqProtocol
}
x
%{
tag
:
RespReason
}
x
%{
tag
:
RespStatus
}
x
cformat
+=%{
tag
:
Timestamp
:
Req
}
x
%{
tag
:
ReqAcct
[
5
]}
x
%{
tag
:
Timestamp
:
Req
[
2
]}
x
cformat
+=%{
VSL
:
Begin
}
x
%{
VSL
:
Debug
}
x
%{
VSL
:
End
}
x
%{
VSL
:
Gzip
}
x
%{
VSL
:
Hit
}
x
cformat
+=%{
VSL
:
Length
}
x
%{
VSL
:
Link
}
x
%{
VSL
:
ReqAcct
}
x
%{
VSL
:
ReqStart
}
x
cformat
+=%{
VSL
:
RespProtocol
}
x
%{
VSL
:
ReqMethod
}
x
%{
VSL
:
ReqURL
}
x
cformat
+=%{
VSL
:
ReqProtocol
}
x
%{
VSL
:
RespReason
}
x
%{
VSL
:
RespStatus
}
x
cformat
+=%{
VSL
:
Timestamp
:
Req
}
x
%{
VSL
:
ReqAcct
[
5
]}
x
%{
VSL
:
Timestamp
:
Req
[
2
]}
x
cformat
+=%{
VSL
:
Timestamp
}
x
%{
vxid
}
x
%{
Varnish
:
vxid
}
x
%{
pvxid
}
x
%{
Varnish
:
side
}
x
bformat
=%
b
%
d
%
D
%
H
%
h
%
I
%{
Accept
-
Encoding
}
i
%{
Host
}
i
%{
User
-
Agent
}
i
%{
X
-
Forwarded
-
For
}
i
%{
X
-
Varnish
}
i
%{
Accept
-
Ranges
}
o
%{
Connection
}
o
%{
Content
-
Encoding
}
o
%{
Content
-
Length
}
o
%{
Content
-
Type
}
o
%{
Date
}
o
%{
ETag
}
o
%{
Last
-
Modified
}
o
%{
Server
}
o
%{
Transfer
-
Encoding
}
o
%{
Vary
}
o
%
l
%
m
%
O
%
q
%
r
%
s
%
t
%{%
F
-%
T
}
t
%
U
%
u
%{
Varnish
:
time_firstbyte
}
x
%{
tag
:
Backend
}
x
%{
tag
:
BackendOpen
}
x
%{
tag
:
BackendClose
}
x
%{
tag
:
BackendReuse
}
x
%{
tag
:
Begin
}
x
%{
tag
:
BereqAcct
}
x
%{
tag
:
Length
}
x
%{
tag
:
BerespProtocol
}
x
%{
tag
:
BerespReason
}
x
%{
tag
:
BerespStatus
}
x
%{
tag
:
BereqProtocol
}
x
%{
tag
:
BereqMethod
}
x
%{
tag
:
BereqURL
}
x
%{
tag
:
Debug
}
x
%{
tag
:
End
}
x
%{
tag
:
Timestamp
:
Bereq
}
x
%{
tag
:
BereqAcct
[
5
]}
x
%{
tag
:
Timestamp
:
Bereq
[
2
]}
x
%{
VSL
:
Backend
}
x
%{
VSL
:
BackendOpen
}
x
%{
VSL
:
BackendClose
}
x
%{
VSL
:
BackendReuse
}
x
%{
VSL
:
Begin
}
x
%{
VSL
:
BereqAcct
}
x
%{
VSL
:
Length
}
x
%{
VSL
:
BerespProtocol
}
x
%{
VSL
:
BerespReason
}
x
%{
VSL
:
BerespStatus
}
x
%{
VSL
:
BereqProtocol
}
x
%{
VSL
:
BereqMethod
}
x
%{
VSL
:
BereqURL
}
x
%{
VSL
:
Debug
}
x
%{
VSL
:
End
}
x
%{
VSL
:
Timestamp
:
Bereq
}
x
%{
VSL
:
BereqAcct
[
5
]}
x
%{
VSL
:
Timestamp
:
Bereq
[
2
]}
x
%{
VSL
:
Timestamp
}
x
%{
vxid
}
x
%{
Varnish
:
vxid
}
x
%{
pvxid
}
x
%{
Varnish
:
side
}
x
bformat
=%
b
%
d
%
D
%
H
%
h
%
I
%{
Accept
-
Encoding
}
i
%{
Host
}
i
%{
User
-
Agent
}
i
bformat
+=%{
X
-
Forwarded
-
For
}
i
%{
X
-
Varnish
}
i
%{
Accept
-
Ranges
}
o
%{
Connection
}
o
bformat
+=%{
Content
-
Encoding
}
o
%{
Content
-
Length
}
o
%{
Content
-
Type
}
o
%{
Date
}
o
bformat
+=%{
ETag
}
o
%{
Last
-
Modified
}
o
%{
Server
}
o
%{
Transfer
-
Encoding
}
o
%{
Vary
}
o
bformat
+=%
l
%
m
%
O
%
q
%
r
%
s
%
t
%{%
F
-%
T
}
t
%
U
%
u
%{
Varnish
:
time_firstbyte
}
x
bformat
+=%{
tag
:
Backend
}
x
%{
tag
:
BackendOpen
}
x
%{
tag
:
BackendClose
}
x
bformat
+=%{
tag
:
BackendReuse
}
x
%{
tag
:
Begin
}
x
%{
tag
:
BereqAcct
}
x
%{
tag
:
Length
}
x
bformat
+=%{
tag
:
BerespProtocol
}
x
%{
tag
:
BerespReason
}
x
%{
tag
:
BerespStatus
}
x
bformat
+=%{
tag
:
BereqProtocol
}
x
%{
tag
:
BereqMethod
}
x
%{
tag
:
BereqURL
}
x
bformat
+=%{
tag
:
Debug
}
x
%{
tag
:
End
}
x
%{
tag
:
Timestamp
:
Bereq
}
x
%{
tag
:
BereqAcct
[
5
]}
x
bformat
+=%{
tag
:
Timestamp
:
Bereq
[
2
]}
x
%{
VSL
:
Backend
}
x
%{
VSL
:
BackendOpen
}
x
bformat
+=%{
VSL
:
BackendClose
}
x
%{
VSL
:
BackendReuse
}
x
%{
VSL
:
Begin
}
x
bformat
+=%{
VSL
:
BereqAcct
}
x
%{
VSL
:
Length
}
x
%{
VSL
:
BerespProtocol
}
x
bformat
+=%{
VSL
:
BerespReason
}
x
%{
VSL
:
BerespStatus
}
x
%{
VSL
:
BereqProtocol
}
x
bformat
+=%{
VSL
:
BereqMethod
}
x
%{
VSL
:
BereqURL
}
x
%{
VSL
:
Debug
}
x
%{
VSL
:
End
}
x
bformat
+=%{
VSL
:
Timestamp
:
Bereq
}
x
%{
VSL
:
BereqAcct
[
5
]}
x
bformat
+=%{
VSL
:
Timestamp
:
Bereq
[
2
]}
x
%{
VSL
:
Timestamp
}
x
%{
vxid
}
x
%{
Varnish
:
vxid
}
x
bformat
+=%{
pvxid
}
x
%{
Varnish
:
side
}
x
log
.
file
=
test
.
log
src/varnishevent.c
View file @
e0e3eb7d
...
...
@@ -628,7 +628,6 @@ main(int argc, char *argv[])
case
'F'
:
VSB_clear
(
config
.
cformat
);
VSB_cat
(
config
.
cformat
,
optarg
);
VSB_finish
(
config
.
cformat
);
break
;
case
'D'
:
#ifdef HAVE_DAEMON
...
...
@@ -704,6 +703,8 @@ main(int argc, char *argv[])
}
}
CONF_Fini
();
if
(
!
EMPTY
(
config
.
varnish_bindump
)
&&
(
n_arg
))
{
fprintf
(
stderr
,
"Cannot specify -r/varnish.bindump together with -n
\n
"
);
usage
(
EXIT_FAILURE
);
...
...
src/varnishevent.h
View file @
e0e3eb7d
...
...
@@ -215,7 +215,7 @@ int RDR_Waiting(void);
/* config.c */
void
CONF_Init
(
void
);
int
CONF_Add
(
const
char
*
lval
,
const
char
*
rval
);
void
CONF_Fini
(
void
);
int
CONF_ReadFile
(
const
char
*
file
);
void
CONF_Dump
(
void
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment