Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
467f10c5
Commit
467f10c5
authored
May 13, 2018
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement backend.list -j
parent
6aacf4db
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
79 additions
and
12 deletions
+79
-12
cache_backend.c
bin/varnishd/cache/cache_backend.c
+4
-3
cache_backend.h
bin/varnishd/cache/cache_backend.h
+1
-1
cache_backend_probe.c
bin/varnishd/cache/cache_backend_probe.c
+22
-4
cache_director.c
bin/varnishd/cache/cache_director.c
+48
-4
d00005.vtc
bin/varnishtest/tests/d00005.vtc
+3
-0
v00014.vtc
bin/varnishtest/tests/v00014.vtc
+1
-0
No files found.
bin/varnishd/cache/cache_backend.c
View file @
467f10c5
...
...
@@ -418,11 +418,12 @@ vbe_list(const struct director *d, struct vsb *vsb, int vflag, int pflag,
CHECK_OBJ_NOTNULL
(
d
,
DIRECTOR_MAGIC
);
CAST_OBJ_NOTNULL
(
bp
,
d
->
priv
,
BACKEND_MAGIC
);
AZ
(
jflag
);
if
(
bp
->
probe
!=
NULL
)
VBP_Status
(
vsb
,
bp
,
vflag
|
pflag
);
else
if
((
vflag
|
pflag
)
==
0
)
VBP_Status
(
vsb
,
bp
,
vflag
|
pflag
,
jflag
);
else
if
((
vflag
|
pflag
)
==
0
&&
jflag
)
VSB_printf
(
vsb
,
"
\"
%s
\"
,
\n
"
,
d
->
sick
?
"sick"
:
"healthy"
);
else
VSB_printf
(
vsb
,
"%-10s"
,
d
->
sick
?
"sick"
:
"healthy"
);
}
...
...
bin/varnishd/cache/cache_backend.h
View file @
467f10c5
...
...
@@ -81,4 +81,4 @@ void VBP_Insert(struct backend *b, struct vrt_backend_probe const *p,
struct
tcp_pool
*
);
void
VBP_Remove
(
struct
backend
*
b
);
void
VBP_Control
(
const
struct
backend
*
b
,
int
stop
);
void
VBP_Status
(
struct
vsb
*
,
const
struct
backend
*
,
int
details
);
void
VBP_Status
(
struct
vsb
*
,
const
struct
backend
*
,
int
details
,
int
json
);
bin/varnishd/cache/cache_backend_probe.c
View file @
467f10c5
...
...
@@ -473,7 +473,7 @@ vbp_bitmap(struct vsb *vsb, char c, uint64_t map, const char *lbl)
/*lint -e{506} constant value boolean */
/*lint -e{774} constant value boolean */
void
VBP_Status
(
struct
vsb
*
vsb
,
const
struct
backend
*
be
,
int
details
)
VBP_Status
(
struct
vsb
*
vsb
,
const
struct
backend
*
be
,
int
details
,
int
json
)
{
struct
vbp_target
*
vt
;
char
buf
[
12
];
...
...
@@ -483,9 +483,27 @@ VBP_Status(struct vsb *vsb, const struct backend *be, int details)
CHECK_OBJ_NOTNULL
(
vt
,
VBP_TARGET_MAGIC
);
if
(
!
details
)
{
bprintf
(
buf
,
"%d/%d %s"
,
vt
->
good
,
vt
->
window
,
vt
->
backend
->
director
->
sick
?
"bad"
:
"good"
);
VSB_printf
(
vsb
,
"%-10s"
,
buf
);
if
(
json
)
{
VSB_printf
(
vsb
,
"[%u, %u,
\"
%s
\"
]"
,
vt
->
good
,
vt
->
window
,
vt
->
backend
->
director
->
sick
?
"bad"
:
"good"
);
}
else
{
bprintf
(
buf
,
"%u/%u %s"
,
vt
->
good
,
vt
->
window
,
vt
->
backend
->
director
->
sick
?
"bad"
:
"good"
);
VSB_printf
(
vsb
,
"%-10s"
,
buf
);
}
return
;
}
if
(
json
)
{
VSB_printf
(
vsb
,
"{
\n
"
);
#define BITMAP(nn, cc, tt, bb) \
VSB_printf(vsb, "\t \"bits_%c\": %ju,\n", cc, vt->nn);
#include "tbl/backend_poll.h"
VSB_printf
(
vsb
,
"
\t
\"
good
\"
: %u,
\n
"
,
vt
->
good
);
VSB_printf
(
vsb
,
"
\t
\"
threshold
\"
: %u,
\n
"
,
vt
->
threshold
);
VSB_printf
(
vsb
,
"
\t
\"
window
\"
: %u
\n
"
,
vt
->
window
);
VSB_printf
(
vsb
,
"
\t
},
\n
"
);
return
;
}
...
...
bin/varnishd/cache/cache_director.c
View file @
467f10c5
...
...
@@ -273,6 +273,8 @@ struct list_args {
#define LIST_ARGS_MAGIC 0x7e7cefeb
int
p
;
int
v
;
int
j
;
const
char
*
jsep
;
};
static
int
v_matchproto_
(
vcl_be_func
)
...
...
@@ -302,6 +304,39 @@ do_list(struct cli *cli, struct director *d, void *priv)
return
(
0
);
}
static
int
v_matchproto_
(
vcl_be_func
)
do_list_json
(
struct
cli
*
cli
,
struct
director
*
d
,
void
*
priv
)
{
struct
list_args
*
la
;
CAST_OBJ_NOTNULL
(
la
,
priv
,
LIST_ARGS_MAGIC
);
CHECK_OBJ_NOTNULL
(
d
,
DIRECTOR_MAGIC
);
if
(
d
->
vdir
->
admin_health
==
VDI_AH_DELETED
)
return
(
0
);
VCLI_Out
(
cli
,
"%s"
,
la
->
jsep
);
la
->
jsep
=
",
\n
"
;
// XXX admin health "probe" for the no-probe case is confusing
VCLI_Out
(
cli
,
"
\"
%s
\"
: {
\n
"
,
d
->
vdir
->
cli_name
);
VCLI_Out
(
cli
,
"
\t\"
type
\"
:
\"
%s
\"
,
\n
"
,
d
->
vdir
->
methods
->
type
);
VCLI_Out
(
cli
,
"
\t\"
admin_health
\"
:
\"
%s
\"
,
\n
"
,
VDI_Ahealth
(
d
));
VCLI_Out
(
cli
,
"
\t\"
probe_health
\"
: "
);
if
(
d
->
vdir
->
methods
->
list
!=
NULL
)
d
->
vdir
->
methods
->
list
(
d
,
cli
->
sb
,
0
,
0
,
1
);
else
VCLI_Out
(
cli
,
"
\"
%s
\"
"
,
d
->
sick
?
"sick"
:
"healthy"
);
VCLI_Out
(
cli
,
",
\n
"
);
if
((
la
->
p
||
la
->
v
)
&&
d
->
vdir
->
methods
->
list
!=
NULL
)
{
VCLI_Out
(
cli
,
"
\t\"
probe_details
\"
: "
);
d
->
vdir
->
methods
->
list
(
d
,
cli
->
sb
,
la
->
p
,
la
->
v
,
1
);
}
VCLI_Out
(
cli
,
"
\t\"
last_change
\"
: %.3f
\n
}"
,
d
->
vdir
->
health_changed
);
return
(
0
);
}
static
void
v_matchproto_
(
cli_func_t
)
cli_backend_list
(
struct
cli
*
cli
,
const
char
*
const
*
av
,
void
*
priv
)
{
...
...
@@ -311,9 +346,11 @@ cli_backend_list(struct cli *cli, const char * const *av, void *priv)
(
void
)
priv
;
ASSERT_CLI
();
INIT_OBJ
(
la
,
LIST_ARGS_MAGIC
);
la
->
jsep
=
"
\n
"
;
while
(
av
[
2
]
!=
NULL
&&
av
[
2
][
0
]
==
'-'
)
{
for
(
p
=
av
[
2
]
+
1
;
*
p
;
p
++
)
{
switch
(
*
p
)
{
case
'j'
:
la
->
j
=
1
;
break
;
case
'p'
:
la
->
p
=
!
la
->
p
;
break
;
case
'v'
:
la
->
p
=
!
la
->
p
;
break
;
default:
...
...
@@ -329,9 +366,15 @@ cli_backend_list(struct cli *cli, const char * const *av, void *priv)
VCLI_SetResult
(
cli
,
CLIS_PARAM
);
return
;
}
VCLI_Out
(
cli
,
"%-30s %-7s %-10s %s"
,
"Backend name"
,
"Admin"
,
"Probe"
,
"Last change"
);
(
void
)
VCL_IterDirector
(
cli
,
av
[
2
],
do_list
,
la
);
if
(
la
->
j
)
{
VCLI_Out
(
cli
,
"{"
);
(
void
)
VCL_IterDirector
(
cli
,
av
[
2
],
do_list_json
,
la
);
VCLI_Out
(
cli
,
"
\n
}
\n
"
);
}
else
{
VCLI_Out
(
cli
,
"%-30s %-7s %-10s %s"
,
"Backend name"
,
"Admin"
,
"Probe"
,
"Last change"
);
(
void
)
VCL_IterDirector
(
cli
,
av
[
2
],
do_list
,
la
);
}
}
/*---------------------------------------------------------------------*/
...
...
@@ -389,7 +432,8 @@ cli_backend_set_health(struct cli *cli, const char * const *av, void *priv)
/*---------------------------------------------------------------------*/
static
struct
cli_proto
backend_cmds
[]
=
{
{
CLICMD_BACKEND_LIST
,
""
,
cli_backend_list
},
{
CLICMD_BACKEND_LIST
,
""
,
cli_backend_list
,
cli_backend_list
},
{
CLICMD_BACKEND_SET_HEALTH
,
""
,
cli_backend_set_health
},
{
NULL
}
};
...
...
bin/varnishtest/tests/d00005.vtc
View file @
467f10c5
...
...
@@ -94,3 +94,6 @@ client c1 {
rxresp
expect resp.body == "4444"
} -run
varnish v1 -vsl_catchup
varnish v1 -cliok "backend.list -j"
bin/varnishtest/tests/v00014.vtc
View file @
467f10c5
...
...
@@ -50,6 +50,7 @@ varnish v1 -vcl {
} -start
varnish v1 -cliok "backend.list -p"
varnish v1 -cliok "backend.list -j -p"
client c1 {
txreq
...
...
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