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
7d496cc5
Commit
7d496cc5
authored
Apr 20, 2015
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add field selector for %{tag}x formatter
parent
f23a3952
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
134 additions
and
50 deletions
+134
-50
format.c
src/format.c
+78
-41
format.h
src/format.h
+1
-0
regress.sh
src/test/regress.sh
+1
-1
test_format.c
src/test/test_format.c
+50
-4
varnishevent.conf
src/test/varnishevent.conf
+2
-2
vslarg.sh
src/test/vslarg.sh
+2
-2
No files found.
src/format.c
View file @
7d496cc5
This diff is collapsed.
Click to expand it.
src/format.h
View file @
7d496cc5
...
...
@@ -34,6 +34,7 @@
typedef
struct
arg_t
{
char
*
name
;
enum
VSL_tag_e
tag
;
int
fld
;
}
arg_t
;
typedef
void
formatter_f
(
const
tx_t
*
tx
,
const
arg_t
*
args
,
char
**
s
,
...
...
src/test/regress.sh
View file @
7d496cc5
...
...
@@ -12,7 +12,7 @@ rm -f $LOG $OUT
../varnishevent
-f
varnishevent.conf
-r
sw-doc.log
-w
$OUT
-v
CKSUM
=
$(
cksum
$OUT
)
if
[
"
$CKSUM
"
!=
"4
178357783 2192069
8
$OUT
"
]
;
then
if
[
"
$CKSUM
"
!=
"4
053530460 2232772
8
$OUT
"
]
;
then
echo
"ERROR: Regression test log output incorrect cksum:
$CKSUM
"
exit
1
fi
...
...
src/test/test_format.c
View file @
7d496cc5
...
...
@@ -1257,6 +1257,7 @@ static const char
set_record_data
(
&
rec
,
&
chunk
,
"no backend connection"
,
SLT_FetchError
);
args
.
tag
=
SLT_FetchError
;
args
.
fld
=
-
1
;
format_SLT
(
&
tx
,
&
args
,
&
str
,
&
len
);
MASSERT
(
strncmp
(
str
,
"no backend connection"
,
21
)
==
0
);
MASSERT
(
len
==
21
);
...
...
@@ -1292,6 +1293,49 @@ static const char
MASSERT
(
strncmp
(
str
,
substr
,
strlen
(
substr
))
==
0
);
MASSERT
(
len
==
strlen
(
substr
));
/* field selector */
set_record_data
(
&
rec
,
&
chunk
,
TS_RESP_PAYLOAD
,
SLT_Timestamp
);
args
.
name
=
NULL
;
args
.
fld
=
0
;
format_SLT
(
&
tx
,
&
args
,
&
str
,
&
len
);
MASSERT
(
strncmp
(
str
,
"Resp:"
,
5
)
==
0
);
MASSERT
(
len
==
5
);
/* header and field selector */
set_record_data
(
&
rec
,
&
chunk
,
TS_RESP_PAYLOAD
,
SLT_Timestamp
);
args
.
name
=
strdup
(
"Resp"
);
format_SLT
(
&
tx
,
&
args
,
&
str
,
&
len
);
MASSERT
(
strncmp
(
str
,
substr
,
len
)
==
0
);
MASSERT
(
len
==
strlen
(
"1427799478.166798"
));
/* header not found */
set_record_data
(
&
rec
,
&
chunk
,
TS_RESP_PAYLOAD
,
SLT_Timestamp
);
args
.
name
=
strdup
(
"Foo"
);
args
.
fld
=
-
1
;
str
=
NULL
;
len
=
0
;
format_SLT
(
&
tx
,
&
args
,
&
str
,
&
len
);
MAZ
(
str
);
MAZ
(
len
);
/* field not found */
set_record_data
(
&
rec
,
&
chunk
,
TS_RESP_PAYLOAD
,
SLT_Timestamp
);
args
.
name
=
NULL
;
args
.
fld
=
4
;
str
=
NULL
;
len
=
0
;
format_SLT
(
&
tx
,
&
args
,
&
str
,
&
len
);
MAZ
(
len
);
/* header field not found */
set_record_data
(
&
rec
,
&
chunk
,
TS_RESP_PAYLOAD
,
SLT_Timestamp
);
args
.
name
=
strdup
(
"Resp"
);
args
.
fld
=
3
;
str
=
NULL
;
len
=
0
;
format_SLT
(
&
tx
,
&
args
,
&
str
,
&
len
);
MAZ
(
len
);
return
NULL
;
}
...
...
@@ -1388,7 +1432,8 @@ static const char
#define FULL_CLIENT_FMT "%b %d %D %H %h %I %{Foo}i %{Bar}o %l %m %O %q %r %s "\
"%t %T %{%F-%T.%i}t %U %u %{Varnish:time_firstbyte}x "\
"%{Varnish:hitmiss}x %{Varnish:handling}x %{VCL_Log:baz}x "\
"%{tag:VCL_acl}x %{tag:Debug}x %{tag:Timestamp:Req}x"
"%{tag:VCL_acl}x %{tag:Debug}x %{tag:Timestamp:Req}x "\
"%{tag:ReqAcct[0]}x %{tag:Timestamp:Resp[2]}x"
strcpy
(
config
.
cformat
,
FULL_CLIENT_FMT
);
status
=
FMT_Init
(
err
);
VMASSERT
(
status
==
0
,
"FMT_Init: %s"
,
err
);
...
...
@@ -1435,7 +1480,7 @@ static const char
"http://bazquux.com/foo?bar=baz&quux=wilco HTTP/1.1 200 "\
"[%d/%b/%Y:%T %z] 0 %F-%T.529143 /foo varnish 0.000166 hit hit "\
"logload MATCH ACL \"10.0.0.0\"/8 \"foo\\0\\377 bar\" " \
"1429213569.602005 0.000000 0.000000\n"
"1429213569.602005 0.000000 0.000000
60 0.000125
\n"
tm
=
localtime
(
&
t
);
MAN
(
strftime
(
strftime_s
,
BUFSIZ
,
EXP_FULL_CLIENT_OUTPUT
,
tm
));
VMASSERT
(
strcmp
(
VSB_data
(
os
),
strftime_s
)
==
0
,
"'%s' != '%s'"
,
...
...
@@ -1447,7 +1492,8 @@ static const char
#define FULL_BACKEND_FMT "%b %d %D %H %h %I %{Foo}i %{Bar}o %l %m %O %q %r %s "\
"%t %T %{%F-%T.%i}t %U %u %{Varnish:time_firstbyte}x %{VCL_Log:baz}x "\
"%{tag:Fetch_Body}x %{tag:Debug}x %{tag:Timestamp:Bereq}x"
"%{tag:Fetch_Body}x %{tag:Debug}x %{tag:Timestamp:Bereq}x "\
"%{tag:BereqAcct[5]}x %{tag:Timestamp:Bereq[1]}x"
strcpy
(
config
.
bformat
,
FULL_BACKEND_FMT
);
config
.
cformat
[
0
]
=
'\0'
;
status
=
FMT_Init
(
err
);
...
...
@@ -1500,7 +1546,7 @@ static const char
"http://bazquux.com/foo?bar=baz&quux=wilco HTTP/1.1 200 "\
"[%d/%b/%Y:%T %z] 0 %F-%T.529143 /foo varnish 0.002837 logload "\
"2 chunked stream \"foo\\0\\377 bar\" "\
"1429210777.728290 0.000048 0.000048\n"
"1429210777.728290 0.000048 0.000048
283 0.000048
\n"
tm
=
localtime
(
&
t
);
MAN
(
strftime
(
strftime_s
,
BUFSIZ
,
EXP_FULL_BACKEND_OUTPUT
,
tm
));
VMASSERT
(
strcmp
(
VSB_data
(
os
),
strftime_s
)
==
0
,
"'%s' != '%s'"
,
...
...
src/test/varnishevent.conf
View file @
7d496cc5
...
...
@@ -2,8 +2,8 @@
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
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
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
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
log
.
file
=
test
.
log
src/test/vslarg.sh
View file @
7d496cc5
...
...
@@ -11,7 +11,7 @@ echo "... -g vxid"
CKSUM
=
$(
../varnishevent
-g
vxid
-r
sw-doc.log
-f
varnishevent.conf |
cksum
)
# Same as default (no -g arg)
if
[
"
$CKSUM
"
!=
'2
669898744 2192073
6'
]
;
then
if
[
"
$CKSUM
"
!=
'2
110242182 2232776
6'
]
;
then
echo
"ERROR: -g vxid unexpected cksum:
$CKSUM
"
exit
1
fi
...
...
@@ -19,7 +19,7 @@ fi
echo
"... -g request"
CKSUM
=
$(
../varnishevent
-g
request
-r
sw-doc.log
-f
varnishevent.conf |
cksum
)
if
[
"
$CKSUM
"
!=
'1
458016223 2192073
6'
]
;
then
if
[
"
$CKSUM
"
!=
'1
162377575 2232776
6'
]
;
then
echo
"ERROR: -g request unexpected cksum:
$CKSUM
"
exit
1
fi
...
...
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