Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
unique-xids
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
unique-xids
Commits
1f3fbd8e
Commit
1f3fbd8e
authored
Nov 23, 2011
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make VSC/varnishstat sorta-work again.
parent
6cc6f23f
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
297 additions
and
151 deletions
+297
-151
varnishstat.c
bin/varnishstat/varnishstat.c
+22
-22
varnishstat_curses.c
bin/varnishstat/varnishstat_curses.c
+6
-10
vsc.h
include/vapi/vsc.h
+37
-19
vsc.c
lib/libvarnishapi/vsc.c
+231
-99
vsm.c
lib/libvarnishapi/vsm.c
+1
-1
No files found.
bin/varnishstat/varnishstat.c
View file @
1f3fbd8e
...
...
@@ -52,7 +52,9 @@ do_xml_cb(void *priv, const struct VSC_point * const pt)
uint64_t
val
;
(
void
)
priv
;
assert
(
!
strcmp
(
pt
->
fmt
,
"uint64_t"
));
if
(
pt
==
NULL
)
return
(
0
);
assert
(
!
strcmp
(
pt
->
desc
->
fmt
,
"uint64_t"
));
val
=
*
(
const
volatile
uint64_t
*
)
pt
->
ptr
;
printf
(
"
\t
<stat>
\n
"
);
...
...
@@ -60,10 +62,10 @@ do_xml_cb(void *priv, const struct VSC_point * const pt)
printf
(
"
\t\t
<type>%s</type>
\n
"
,
pt
->
class
);
if
(
strcmp
(
pt
->
ident
,
""
))
printf
(
"
\t\t
<ident>%s</ident>
\n
"
,
pt
->
ident
);
printf
(
"
\t\t
<name>%s</name>
\n
"
,
pt
->
name
);
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
->
flag
);
printf
(
"
\t\t
<description>%s</description>
\n
"
,
pt
->
desc
);
printf
(
"
\t\t
<flag>%c</flag>
\n
"
,
pt
->
desc
->
flag
);
printf
(
"
\t\t
<description>%s</description>
\n
"
,
pt
->
desc
->
sdesc
);
printf
(
"
\t
</stat>
\n
"
);
return
(
0
);
}
...
...
@@ -91,9 +93,11 @@ do_json_cb(void *priv, const struct VSC_point * const pt)
uint64_t
val
;
int
*
jp
;
jp
=
priv
;
if
(
pt
==
NULL
)
return
(
0
);
assert
(
!
strcmp
(
pt
->
fmt
,
"uint64_t"
));
jp
=
priv
;
assert
(
!
strcmp
(
pt
->
desc
->
fmt
,
"uint64_t"
));
val
=
*
(
const
volatile
uint64_t
*
)
pt
->
ptr
;
if
(
*
jp
)
*
jp
=
0
;
else
printf
(
",
\n
"
);
...
...
@@ -104,15 +108,15 @@ do_json_cb(void *priv, const struct VSC_point * const pt)
printf
(
"%s."
,
pt
->
class
);
if
(
pt
->
ident
[
0
])
printf
(
"%s."
,
pt
->
ident
);
printf
(
"%s
\"
: {"
,
pt
->
name
);
printf
(
"%s
\"
: {"
,
pt
->
desc
->
name
);
if
(
strcmp
(
pt
->
class
,
""
))
printf
(
"
\"
type
\"
:
\"
%s
\"
, "
,
pt
->
class
);
if
(
strcmp
(
pt
->
ident
,
""
))
printf
(
"
\"
ident
\"
:
\"
%s
\"
, "
,
pt
->
ident
);
printf
(
"
\"
value
\"
: %ju, "
,
val
);
printf
(
"
\"
flag
\"
:
\"
%c
\"
, "
,
pt
->
flag
);
printf
(
"
\"
description
\"
:
\"
%s
\"
"
,
pt
->
desc
);
printf
(
"
\"
flag
\"
:
\"
%c
\"
, "
,
pt
->
desc
->
flag
);
printf
(
"
\"
description
\"
:
\"
%s
\"
"
,
pt
->
desc
->
sdesc
);
printf
(
"}"
);
if
(
*
jp
)
printf
(
"
\n
"
);
...
...
@@ -153,22 +157,24 @@ do_once_cb(void *priv, const struct VSC_point * const pt)
uint64_t
val
;
int
i
;
if
(
pt
==
NULL
)
return
(
0
);
op
=
priv
;
assert
(
!
strcmp
(
pt
->
fmt
,
"uint64_t"
));
assert
(
!
strcmp
(
pt
->
desc
->
fmt
,
"uint64_t"
));
val
=
*
(
const
volatile
uint64_t
*
)
pt
->
ptr
;
i
=
0
;
if
(
strcmp
(
pt
->
class
,
""
))
i
+=
printf
(
"%s."
,
pt
->
class
);
if
(
strcmp
(
pt
->
ident
,
""
))
i
+=
printf
(
"%s."
,
pt
->
ident
);
i
+=
printf
(
"%s"
,
pt
->
name
);
i
+=
printf
(
"%s"
,
pt
->
desc
->
name
);
if
(
i
>
op
->
pad
)
op
->
pad
=
i
+
1
;
printf
(
"%*.*s"
,
op
->
pad
-
i
,
op
->
pad
-
i
,
""
);
if
(
pt
->
flag
==
'a'
||
pt
->
flag
==
'c'
)
printf
(
"%12ju %12.2f %s
\n
"
,
val
,
val
/
op
->
up
,
pt
->
desc
);
if
(
pt
->
desc
->
flag
==
'a'
||
pt
->
desc
->
flag
==
'c'
)
printf
(
"%12ju %12.2f %s
\n
"
,
val
,
val
/
op
->
up
,
pt
->
desc
->
sdesc
);
else
printf
(
"%12ju %12s %s
\n
"
,
val
,
". "
,
pt
->
desc
);
printf
(
"%12ju %12s %s
\n
"
,
val
,
". "
,
pt
->
desc
->
sdesc
);
return
(
0
);
}
...
...
@@ -197,10 +203,10 @@ do_list_cb(void *priv, const struct VSC_point * const pt)
i
+=
fprintf
(
stderr
,
"%s."
,
pt
->
class
);
if
(
strcmp
(
pt
->
ident
,
""
))
i
+=
fprintf
(
stderr
,
"%s."
,
pt
->
ident
);
i
+=
fprintf
(
stderr
,
"%s"
,
pt
->
name
);
i
+=
fprintf
(
stderr
,
"%s"
,
pt
->
desc
->
name
);
if
(
i
<
30
)
fprintf
(
stderr
,
"%*s"
,
i
-
30
,
""
);
fprintf
(
stderr
,
" %s
\n
"
,
pt
->
desc
);
fprintf
(
stderr
,
" %s
\n
"
,
pt
->
desc
->
sdesc
);
return
(
0
);
}
...
...
@@ -253,7 +259,6 @@ main(int argc, char * const *argv)
int
delay
=
1
,
once
=
0
,
xml
=
0
,
json
=
0
,
do_repeat
=
0
;
vd
=
VSM_New
();
VSC_Setup
(
vd
);
while
((
c
=
getopt
(
argc
,
argv
,
VSC_ARGS
"1f:lVw:xjt:"
))
!=
-
1
)
{
switch
(
c
)
{
...
...
@@ -261,8 +266,6 @@ main(int argc, char * const *argv)
once
=
1
;
break
;
case
'l'
:
if
(
VSC_Open
(
vd
,
1
))
exit
(
1
);
list_fields
(
vd
);
exit
(
0
);
case
'V'
:
...
...
@@ -285,9 +288,6 @@ main(int argc, char * const *argv)
}
}
if
(
VSC_Open
(
vd
,
1
))
exit
(
1
);
VSC_C_main
=
VSC_Main
(
vd
);
AN
(
VSC_C_main
);
...
...
bin/varnishstat/varnishstat_curses.c
View file @
1f3fbd8e
...
...
@@ -81,7 +81,9 @@ do_curses_cb(void *priv, const struct VSC_point * const sp)
char
buf
[
128
];
(
void
)
priv
;
assert
(
!
strcmp
(
sp
->
fmt
,
"uint64_t"
));
if
(
sp
==
NULL
)
return
(
0
);
assert
(
!
strcmp
(
sp
->
desc
->
fmt
,
"uint64_t"
));
pt
=
calloc
(
sizeof
*
pt
,
1
);
AN
(
pt
);
...
...
@@ -89,7 +91,7 @@ do_curses_cb(void *priv, const struct VSC_point * const sp)
pt
->
ptr
=
sp
->
ptr
;
pt
->
ref
=
*
pt
->
ptr
;
pt
->
flag
=
sp
->
flag
;
pt
->
flag
=
sp
->
desc
->
flag
;
*
buf
=
'\0'
;
if
(
strcmp
(
sp
->
class
,
""
))
{
...
...
@@ -100,9 +102,9 @@ do_curses_cb(void *priv, const struct VSC_point * const sp)
strcat
(
buf
,
sp
->
ident
);
strcat
(
buf
,
"."
);
}
strcat
(
buf
,
sp
->
name
);
strcat
(
buf
,
sp
->
desc
->
name
);
strcat
(
buf
,
" - "
);
strcat
(
buf
,
sp
->
desc
);
strcat
(
buf
,
sp
->
desc
->
sdesc
);
pt
->
name
=
strdup
(
buf
);
AN
(
pt
->
name
);
return
(
0
);
...
...
@@ -144,7 +146,6 @@ do_curses(struct VSM_data *vd, const struct VSC_C_main *VSC_C_main,
int
ch
,
line
;
struct
pt
*
pt
;
double
act
,
lact
;
unsigned
seq
;
(
void
)
initscr
();
AC
(
raw
());
...
...
@@ -157,7 +158,6 @@ do_curses(struct VSM_data *vd, const struct VSC_C_main *VSC_C_main,
/*
* Initialization goes in outher loop
*/
seq
=
VSM_Seq
(
vd
);
prep_pts
(
vd
);
AC
(
erase
());
AC
(
refresh
());
...
...
@@ -170,15 +170,11 @@ do_curses(struct VSM_data *vd, const struct VSC_C_main *VSC_C_main,
lact
=
0
;
while
(
1
)
{
if
(
seq
!=
VSM_Seq
(
vd
))
break
;
/*
* Break to outher loop if we need to re-read file.
* Only check if it looks like nothing is happening.
*/
act
=
VSC_C_main
->
cache_hit
+
VSC_C_main
->
cache_miss
+
1
;
if
(
act
==
lact
&&
VSM_ReOpen
(
vd
,
1
))
break
;
lact
=
act
;
AZ
(
gettimeofday
(
&
tv
,
NULL
));
...
...
include/vapi/vsc.h
View file @
1f3fbd8e
...
...
@@ -26,6 +26,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This is the public API for the VSC access.
*
* VSC is a "subclass" of VSM.
*
*/
#ifndef VAPI_VSC_H_INCLUDED
...
...
@@ -34,17 +38,12 @@
#include "vapi/vsc_int.h"
struct
VSM_data
;
struct
VSM_fantom
;
/*---------------------------------------------------------------------
* VSC level access functions
*/
void
VSC_Setup
(
struct
VSM_data
*
vd
);
/*
* Setup vd for use with VSC functions.
* Must be called once before any other VSC function is called
*/
#define VSC_ARGS "f:n:"
#define VSC_n_USAGE VSM_n_USAGE
#define VSC_f_USAGE "[-f field_name,...]"
...
...
@@ -55,39 +54,58 @@ int VSC_Arg(struct VSM_data *vd, int arg, const char *opt);
/*
* Handle standard stat-presenter arguments
* Return:
* -1 error
* -1 error
, VSM_Error() returns diagnostic string
* 0 not handled
* 1 Handled.
*/
int
VSC_Open
(
struct
VSM_data
*
vd
,
int
diag
);
/*
* Open shared memory for VSC processing.
* args and returns as VSM_Open()
*/
struct
VSC_C_main
*
VSC_Main
(
const
struct
VSM_data
*
vd
);
struct
VSC_C_main
*
VSC_Main
(
struct
VSM_data
*
vd
);
/*
* return Main stats structure
* returns NULL until child has been started.
*/
struct
VSC_desc
{
const
char
*
name
;
/* field name */
const
char
*
fmt
;
/* field format ("uint64_t") */
int
flag
;
/* 'c' = counter, 'g' = gauge */
const
char
*
sdesc
;
/* short description */
const
char
*
ldesc
;
/* long description */
};
struct
VSC_point
{
const
char
*
class
;
/* stat struct type */
const
char
*
ident
;
/* stat struct ident */
const
char
*
name
;
/* field name */
const
char
*
fmt
;
/* field format ("uint64_t") */
int
flag
;
/* 'a' = counter, 'i' = gauge */
const
char
*
desc
;
/* description */
const
struct
VSC_desc
*
desc
;
/* point description */
const
volatile
void
*
ptr
;
/* field value */
struct
VSM_fantom
*
vf
;
};
typedef
int
VSC_iter_f
(
void
*
priv
,
const
struct
VSC_point
*
const
pt
);
int
VSC_Iter
(
const
struct
VSM_data
*
vd
,
VSC_iter_f
*
func
,
void
*
priv
);
int
VSC_Iter
(
struct
VSM_data
*
vd
,
VSC_iter_f
*
func
,
void
*
priv
);
/*
* Iterate over all statistics counters, calling "func" for
* each counter not suppressed by any "-f" arguments.
*
* Func is called with pt == NULL, whenever VSM allocations
* change (child restart, allocations/deallocations)
*
* Returns:
* !=0: func returned non-zero
* -1: No VSC's available
* 0: Done
*/
/**********************************************************************
* Precompiled VSC_desc's for all know VSCs.
*/
#define VSC_F(n,t,l,f,d,e)
#define VSC_DO(U,l,t) extern const struct VSC_desc VSC_desc_##l[];
#define VSC_DONE(U,l,t)
#include "tbl/vsc_all.h"
#undef VSC_F
#undef VSC_DO
#undef VSC_DONE
#endif
/* VAPI_VSC_H_INCLUDED */
lib/libvarnishapi/vsc.c
View file @
1f3fbd8e
This diff is collapsed.
Click to expand it.
lib/libvarnishapi/vsm.c
View file @
1f3fbd8e
...
...
@@ -113,7 +113,7 @@ VSM_n_Arg(struct VSM_data *vd, const char *opt)
{
CHECK_OBJ_NOTNULL
(
vd
,
VSM_MAGIC
);
AN
(
vd
->
n_
opt
);
AN
(
opt
);
REPLACE
(
vd
->
n_opt
,
opt
);
if
(
VIN_N_Arg
(
vd
->
n_opt
,
NULL
,
NULL
,
&
vd
->
fname
))
...
...
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