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
bcb6b218
Commit
bcb6b218
authored
Feb 27, 2013
by
Martin Blix Grydeland
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add VSC_section information with VSC type description to VSC_point
parent
87c20ed8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
109 additions
and
53 deletions
+109
-53
varnishstat.c
bin/varnishstat/varnishstat.c
+28
-20
varnishstat_curses.c
bin/varnishstat/varnishstat_curses.c
+4
-4
vsc.h
include/vapi/vsc.h
+12
-1
vsc.c
lib/libvarnishapi/vsc.c
+65
-28
No files found.
bin/varnishstat/varnishstat.c
View file @
bcb6b218
...
...
@@ -50,18 +50,20 @@ static int
do_xml_cb
(
void
*
priv
,
const
struct
VSC_point
*
const
pt
)
{
uint64_t
val
;
const
struct
VSC_section
*
sec
;
(
void
)
priv
;
if
(
pt
==
NULL
)
return
(
0
);
assert
(
!
strcmp
(
pt
->
desc
->
fmt
,
"uint64_t"
));
val
=
*
(
const
volatile
uint64_t
*
)
pt
->
ptr
;
sec
=
pt
->
section
;
printf
(
"
\t
<stat>
\n
"
);
if
(
strcmp
(
pt
->
fantom
->
type
,
""
))
printf
(
"
\t\t
<type>%s</type>
\n
"
,
pt
->
fantom
->
type
);
if
(
strcmp
(
pt
->
fantom
->
ident
,
""
))
printf
(
"
\t\t
<ident>%s</ident>
\n
"
,
pt
->
fantom
->
ident
);
if
(
strcmp
(
sec
->
fantom
->
type
,
""
))
printf
(
"
\t\t
<type>%s</type>
\n
"
,
sec
->
fantom
->
type
);
if
(
strcmp
(
sec
->
fantom
->
ident
,
""
))
printf
(
"
\t\t
<ident>%s</ident>
\n
"
,
sec
->
fantom
->
ident
);
printf
(
"
\t\t
<name>%s</name>
\n
"
,
pt
->
desc
->
name
);
printf
(
"
\t\t
<value>%ju</value>
\n
"
,
val
);
printf
(
"
\t\t
<flag>%c</flag>
\n
"
,
pt
->
desc
->
flag
);
...
...
@@ -92,6 +94,7 @@ do_json_cb(void *priv, const struct VSC_point * const pt)
{
uint64_t
val
;
int
*
jp
;
const
struct
VSC_section
*
sec
;
if
(
pt
==
NULL
)
return
(
0
);
...
...
@@ -99,21 +102,22 @@ do_json_cb(void *priv, const struct VSC_point * const pt)
jp
=
priv
;
assert
(
!
strcmp
(
pt
->
desc
->
fmt
,
"uint64_t"
));
val
=
*
(
const
volatile
uint64_t
*
)
pt
->
ptr
;
sec
=
pt
->
section
;
if
(
*
jp
)
*
jp
=
0
;
else
printf
(
",
\n
"
);
printf
(
"
\t\"
"
);
/* build the JSON key name. */
if
(
pt
->
fantom
->
type
[
0
])
printf
(
"%s."
,
pt
->
fantom
->
type
);
if
(
pt
->
fantom
->
ident
[
0
])
printf
(
"%s."
,
pt
->
fantom
->
ident
);
if
(
sec
->
fantom
->
type
[
0
])
printf
(
"%s."
,
sec
->
fantom
->
type
);
if
(
sec
->
fantom
->
ident
[
0
])
printf
(
"%s."
,
sec
->
fantom
->
ident
);
printf
(
"%s
\"
: {"
,
pt
->
desc
->
name
);
if
(
strcmp
(
pt
->
fantom
->
type
,
""
))
printf
(
"
\"
type
\"
:
\"
%s
\"
, "
,
pt
->
fantom
->
type
);
if
(
strcmp
(
pt
->
fantom
->
ident
,
""
))
printf
(
"
\"
ident
\"
:
\"
%s
\"
, "
,
pt
->
fantom
->
ident
);
if
(
strcmp
(
sec
->
fantom
->
type
,
""
))
printf
(
"
\"
type
\"
:
\"
%s
\"
, "
,
sec
->
fantom
->
type
);
if
(
strcmp
(
sec
->
fantom
->
ident
,
""
))
printf
(
"
\"
ident
\"
:
\"
%s
\"
, "
,
sec
->
fantom
->
ident
);
printf
(
"
\"
value
\"
: %ju, "
,
val
);
...
...
@@ -158,17 +162,19 @@ do_once_cb(void *priv, const struct VSC_point * const pt)
struct
once_priv
*
op
;
uint64_t
val
;
int
i
;
const
struct
VSC_section
*
sec
;
if
(
pt
==
NULL
)
return
(
0
);
op
=
priv
;
assert
(
!
strcmp
(
pt
->
desc
->
fmt
,
"uint64_t"
));
val
=
*
(
const
volatile
uint64_t
*
)
pt
->
ptr
;
sec
=
pt
->
section
;
i
=
0
;
if
(
strcmp
(
pt
->
fantom
->
type
,
""
))
i
+=
printf
(
"%s."
,
pt
->
fantom
->
type
);
if
(
strcmp
(
pt
->
fantom
->
ident
,
""
))
i
+=
printf
(
"%s."
,
pt
->
fantom
->
ident
);
if
(
strcmp
(
sec
->
fantom
->
type
,
""
))
i
+=
printf
(
"%s."
,
sec
->
fantom
->
type
);
if
(
strcmp
(
sec
->
fantom
->
ident
,
""
))
i
+=
printf
(
"%s."
,
sec
->
fantom
->
ident
);
i
+=
printf
(
"%s"
,
pt
->
desc
->
name
);
if
(
i
>=
op
->
pad
)
op
->
pad
=
i
+
1
;
...
...
@@ -198,13 +204,15 @@ static int
do_list_cb
(
void
*
priv
,
const
struct
VSC_point
*
const
pt
)
{
int
i
;
const
struct
VSC_section
*
sec
;
(
void
)
priv
;
sec
=
pt
->
section
;
i
=
0
;
if
(
strcmp
(
pt
->
fantom
->
type
,
""
))
i
+=
fprintf
(
stderr
,
"%s."
,
pt
->
fantom
->
type
);
if
(
strcmp
(
pt
->
fantom
->
ident
,
""
))
i
+=
fprintf
(
stderr
,
"%s."
,
pt
->
fantom
->
ident
);
if
(
strcmp
(
sec
->
fantom
->
type
,
""
))
i
+=
fprintf
(
stderr
,
"%s."
,
sec
->
fantom
->
type
);
if
(
strcmp
(
sec
->
fantom
->
ident
,
""
))
i
+=
fprintf
(
stderr
,
"%s."
,
sec
->
fantom
->
ident
);
i
+=
fprintf
(
stderr
,
"%s"
,
pt
->
desc
->
name
);
if
(
i
<
30
)
fprintf
(
stderr
,
"%*s"
,
i
-
30
,
""
);
...
...
bin/varnishstat/varnishstat_curses.c
View file @
bcb6b218
...
...
@@ -94,12 +94,12 @@ do_curses_cb(void *priv, const struct VSC_point * const sp)
pt
->
flag
=
sp
->
desc
->
flag
;
*
buf
=
'\0'
;
if
(
strcmp
(
sp
->
fantom
->
type
,
""
))
{
strcat
(
buf
,
sp
->
fantom
->
type
);
if
(
strcmp
(
sp
->
section
->
fantom
->
type
,
""
))
{
strcat
(
buf
,
sp
->
section
->
fantom
->
type
);
strcat
(
buf
,
"."
);
}
if
(
strcmp
(
sp
->
fantom
->
ident
,
""
))
{
strcat
(
buf
,
sp
->
fantom
->
ident
);
if
(
strcmp
(
sp
->
section
->
fantom
->
ident
,
""
))
{
strcat
(
buf
,
sp
->
section
->
fantom
->
ident
);
strcat
(
buf
,
"."
);
}
strcat
(
buf
,
sp
->
desc
->
name
);
...
...
include/vapi/vsc.h
View file @
bcb6b218
...
...
@@ -65,12 +65,23 @@ struct VSC_C_main *VSC_Main(struct VSM_data *vd);
* returns NULL until child has been started.
*/
struct
VSC_type_desc
;
struct
VSC_section
;
struct
VSC_desc
;
struct
VSC_point
;
struct
VSC_type_desc
{
const
char
*
label
;
/* label */
const
char
*
sdesc
;
/* short description */
const
char
*
ldesc
;
/* long description */
};
struct
VSC_section
{
const
struct
VSC_type_desc
*
desc
;
struct
VSM_fantom
*
fantom
;
const
struct
VSC_point
*
const
*
points
;
};
struct
VSC_desc
{
const
char
*
name
;
/* field name */
const
char
*
fmt
;
/* field format ("uint64_t") */
...
...
@@ -82,7 +93,7 @@ struct VSC_desc {
struct
VSC_point
{
const
struct
VSC_desc
*
desc
;
/* point description */
const
volatile
void
*
ptr
;
/* field value */
struct
VSM_fantom
*
fantom
;
const
struct
VSC_section
*
section
;
};
typedef
int
VSC_iter_f
(
void
*
priv
,
const
struct
VSC_point
*
const
pt
);
...
...
lib/libvarnishapi/vsc.c
View file @
bcb6b218
...
...
@@ -53,6 +53,7 @@ struct vsc_vf {
#define VSC_VF_MAGIC 0x516519f8
VTAILQ_ENTRY
(
vsc_vf
)
list
;
struct
VSM_fantom
fantom
;
struct
VSC_section
section
;
};
struct
vsc_pt
{
...
...
@@ -108,30 +109,39 @@ vsc_setup(struct VSM_data *vd)
/*--------------------------------------------------------------------*/
static
void
vsc_delete_
pts
(
struct
vsc
*
vsc
)
vsc_delete_
vf_list
(
struct
vsc
*
vsc
)
{
struct
vsc_vf
*
vf
;
while
(
!
VTAILQ_EMPTY
(
&
vsc
->
vf_list
))
{
vf
=
VTAILQ_FIRST
(
&
vsc
->
vf_list
);
CHECK_OBJ_NOTNULL
(
vf
,
VSC_VF_MAGIC
);
VTAILQ_REMOVE
(
&
vsc
->
vf_list
,
vf
,
list
);
FREE_OBJ
(
vf
);
}
}
static
void
vsc_delete_pt_list
(
struct
vsc
*
vsc
)
{
struct
vsc_pt
*
pt
;
while
(
!
VTAILQ_EMPTY
(
&
vsc
->
pt_list
))
{
pt
=
VTAILQ_FIRST
(
&
vsc
->
pt_list
);
CHECK_OBJ_NOTNULL
(
pt
,
VSC_PT_MAGIC
);
VTAILQ_REMOVE
(
&
vsc
->
pt_list
,
pt
,
list
);
FREE_OBJ
(
pt
);
}
while
(
!
VTAILQ_EMPTY
(
&
vsc
->
vf_list
))
{
vf
=
VTAILQ_FIRST
(
&
vsc
->
vf_list
);
VTAILQ_REMOVE
(
&
vsc
->
vf_list
,
vf
,
list
);
FREE_OBJ
(
vf
);
}
}
static
void
vsc_delete_sf
s
(
struct
vsc
*
vsc
)
vsc_delete_sf
_list
(
struct
vsc
*
vsc
)
{
struct
vsc_sf
*
sf
;
while
(
!
VTAILQ_EMPTY
(
&
vsc
->
sf_list
))
{
sf
=
VTAILQ_FIRST
(
&
vsc
->
sf_list
);
CHECK_OBJ_NOTNULL
(
sf
,
VSC_SF_MAGIC
);
VTAILQ_REMOVE
(
&
vsc
->
sf_list
,
sf
,
list
);
free
(
sf
->
type
);
free
(
sf
->
ident
);
...
...
@@ -149,8 +159,9 @@ VSC_Delete(struct VSM_data *vd)
vsc
=
vd
->
vsc
;
vd
->
vsc
=
NULL
;
CHECK_OBJ_NOTNULL
(
vsc
,
VSC_MAGIC
);
vsc_delete_sfs
(
vsc
);
vsc_delete_pts
(
vsc
);
vsc_delete_sf_list
(
vsc
);
vsc_delete_pt_list
(
vsc
);
vsc_delete_vf_list
(
vsc
);
FREE_OBJ
(
vsc
);
}
...
...
@@ -257,42 +268,48 @@ VSC_Main(struct VSM_data *vd)
*/
static
void
vsc_add_vf
(
struct
vsc
*
vsc
,
const
struct
VSM_fantom
*
fantom
)
vsc_add_vf
(
struct
vsc
*
vsc
,
struct
VSM_fantom
*
fantom
,
const
struct
VSC_type_desc
*
desc
)
{
struct
vsc_vf
*
vf
;
ALLOC_OBJ
(
vf
,
VSC_VF_MAGIC
);
AN
(
vf
);
vf
->
fantom
=
*
fantom
;
vf
->
section
.
desc
=
desc
;
vf
->
section
.
fantom
=
&
vf
->
fantom
;
VTAILQ_INSERT_TAIL
(
&
vsc
->
vf_list
,
vf
,
list
);
}
static
void
vsc_add_pt
(
struct
vsc
*
vsc
,
const
struct
VSC_desc
*
desc
,
const
volatile
void
*
ptr
,
struct
VSM_fantom
*
fantom
)
vsc_add_pt
(
struct
vsc
*
vsc
,
const
volatile
void
*
ptr
,
const
struct
VSC_desc
*
desc
,
struct
vsc_vf
*
vf
)
{
struct
vsc_pt
*
pt
;
ALLOC_OBJ
(
pt
,
VSC_PT_MAGIC
);
AN
(
pt
);
pt
->
point
.
desc
=
desc
;
pt
->
point
.
ptr
=
ptr
;
pt
->
point
.
fantom
=
fantom
;
pt
->
point
.
section
=
&
vf
->
section
;
VTAILQ_INSERT_TAIL
(
&
vsc
->
pt_list
,
pt
,
list
);
}
#define VSC_DO(U,l,t) \
static void \
iter_##l(struct vsc *vsc, const struct VSC_desc *descs, \
struct
VSM_fantom *fantom)
\
struct
vsc_vf *vf)
\
{ \
struct VSC_C_##l *st; \
\
CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); \
st =
fantom->
b;
st =
vf->fantom.
b;
#define VSC_F(nn,tt,ll,ff,dd,ee) \
vsc_add_pt(vsc,
descs++, &st->nn, fantom
);
vsc_add_pt(vsc,
&st->nn, descs++, vf
);
#define VSC_DONE(U,l,t) \
}
...
...
@@ -308,30 +325,45 @@ vsc_add_pt(struct vsc *vsc, const struct VSC_desc *desc,
#include <stdio.h>
static
void
vsc_build_
pt
_list
(
struct
VSM_data
*
vd
)
vsc_build_
vf
_list
(
struct
VSM_data
*
vd
)
{
struct
vsc
*
vsc
=
vsc_setup
(
vd
);
struct
VSM_fantom
fantom
;
struct
vsc_vf
*
vf
;
vsc_delete_pts
(
vsc
);
vsc_delete_pt_list
(
vsc
);
vsc_delete_vf_list
(
vsc
);
VSM_FOREACH
(
&
fantom
,
vd
)
{
if
(
strcmp
(
fantom
.
class
,
VSC_CLASS
))
continue
;
vsc_add_vf
(
vsc
,
&
fantom
);
#define VSC_TYPE_F(n,t,l,e,d) \
if (!strcmp(fantom.type, t)) \
vsc_add_vf(vsc, &fantom, \
&VSC_type_desc_##n);
#include "tbl/vsc_types.h"
#undef VSC_TYPE_F
}
}
static
void
vsc_build_pt_list
(
struct
VSM_data
*
vd
)
{
struct
vsc
*
vsc
=
vsc_setup
(
vd
);
struct
vsc_vf
*
vf
;
vsc_delete_pt_list
(
vsc
);
VTAILQ_FOREACH
(
vf
,
&
vsc
->
vf_list
,
list
)
{
/*lint -save -e525 -e539 */
#define VSC_F(n,t,l,f,d,e)
#define VSC_DONE(a,b,c)
#define VSC_DO(U,l,t) \
CHECK_OBJ_NOTNULL(vf, VSC_VF_MAGIC); \
if (!strcmp(vf->fantom.type, t)) \
iter_##l(vsc, VSC_desc_##l, &vf->fantom);
iter_##l(vsc, VSC_desc_##l, vf);
#define VSC_F(n,t,l,f,d,e)
#define VSC_DONE(a,b,c)
#include "tbl/vsc_all.h"
#undef VSC_F
#undef VSC_DO
#undef VSC_F
#undef VSC_DONE
/*lint -restore */
}
...
...
@@ -359,6 +391,7 @@ vsc_filter_pt_list(struct VSM_data *vd)
struct
vsc
*
vsc
=
vsc_setup
(
vd
);
struct
vsc_sf
*
sf
;
struct
vsc_pt
*
pt
,
*
pt2
;
const
struct
VSC_section
*
sec
;
VTAILQ_HEAD
(,
vsc_pt
)
pt_list
;
if
(
VTAILQ_EMPTY
(
&
vsc
->
sf_list
))
...
...
@@ -366,11 +399,14 @@ vsc_filter_pt_list(struct VSM_data *vd)
VTAILQ_INIT
(
&
pt_list
);
VTAILQ_FOREACH
(
sf
,
&
vsc
->
sf_list
,
list
)
{
CHECK_OBJ_NOTNULL
(
sf
,
VSC_SF_MAGIC
);
VTAILQ_FOREACH_SAFE
(
pt
,
&
vsc
->
pt_list
,
list
,
pt2
)
{
if
(
iter_test
(
sf
->
type
,
pt
->
point
.
fantom
->
type
,
CHECK_OBJ_NOTNULL
(
pt
,
VSC_PT_MAGIC
);
sec
=
pt
->
point
.
section
;
if
(
iter_test
(
sf
->
type
,
sec
->
fantom
->
type
,
sf
->
flags
&
VSC_SF_TY_WC
))
continue
;
if
(
iter_test
(
sf
->
ident
,
pt
->
point
.
fantom
->
ident
,
if
(
iter_test
(
sf
->
ident
,
sec
->
fantom
->
ident
,
sf
->
flags
&
VSC_SF_ID_WC
))
continue
;
if
(
iter_test
(
sf
->
name
,
pt
->
point
.
desc
->
name
,
...
...
@@ -384,7 +420,7 @@ vsc_filter_pt_list(struct VSM_data *vd)
}
}
}
vsc_delete_pt
s
(
vsc
);
vsc_delete_pt
_list
(
vsc
);
VTAILQ_CONCAT
(
&
vsc
->
pt_list
,
&
pt_list
,
list
);
}
...
...
@@ -401,6 +437,7 @@ VSC_Iter(struct VSM_data *vd, VSC_iter_f *func, void *priv)
if
(
1
!=
VSM_StillValid
(
vd
,
&
vsc
->
iter_fantom
))
{
/* Tell app that list will be nuked */
(
void
)
func
(
priv
,
NULL
);
vsc_build_vf_list
(
vd
);
vsc_build_pt_list
(
vd
);
vsc_filter_pt_list
(
vd
);
}
...
...
@@ -413,7 +450,7 @@ VSC_Iter(struct VSM_data *vd, VSC_iter_f *func, void *priv)
}
/*--------------------------------------------------------------------
* Build the static point descriptions
* Build the static
type and
point descriptions
*/
#define VSC_TYPE_F(n,t,l,e,d) const char *VSC_type_##n = t;
...
...
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