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
fd21faff
Commit
fd21faff
authored
Jun 04, 2016
by
Federico G. Schwindt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle synopsis and options via the vut code
parent
160e1f1a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
145 additions
and
79 deletions
+145
-79
Makefile.am
bin/varnishstat/Makefile.am
+3
-2
varnishstat.c
bin/varnishstat/varnishstat.c
+22
-29
varnishstat_options.c
bin/varnishstat/varnishstat_options.c
+34
-0
varnishstat_options.h
bin/varnishstat/varnishstat_options.h
+73
-0
Makefile.am
doc/sphinx/Makefile.am
+7
-0
varnishstat.rst
doc/sphinx/reference/varnishstat.rst
+3
-46
Makefile.am
man/Makefile.am
+3
-2
No files found.
bin/varnishstat/Makefile.am
View file @
fd21faff
...
...
@@ -8,9 +8,10 @@ bin_PROGRAMS = varnishstat
varnishstat_SOURCES
=
\
varnishstat.h
\
\
varnishstat.c
\
varnishstat_curses.c
varnishstat_curses.c
\
varnishstat_options.h
\
varnishstat_options.c
varnishstat_CFLAGS
=
\
@SAN_CFLAGS@
...
...
bin/varnishstat/varnishstat.c
View file @
fd21faff
...
...
@@ -41,11 +41,16 @@
#include <math.h>
#include <stdint.h>
#include "vapi/voptget.h"
#include "vapi/vsl.h"
#include "vdef.h"
#include "vnum.h"
#include "vtim.h"
#include "vut.h"
#include "varnishstat.h"
static
const
char
progname
[]
=
"varnishstat"
;
/*--------------------------------------------------------------------*/
...
...
@@ -247,50 +252,38 @@ list_fields(struct VSM_data *vd)
/*--------------------------------------------------------------------*/
static
void
usage
(
void
)
usage
(
int
status
)
{
#define FMT " %-28s # %s\n"
fprintf
(
stderr
,
"usage: varnishstat "
"[-1lV] [-f field] [-t seconds|<off>] "
VSC_n_USAGE
"
\n
"
);
fprintf
(
stderr
,
FMT
,
"-1"
,
"Print the statistics to stdout."
);
fprintf
(
stderr
,
FMT
,
"-f field"
,
"Field inclusion glob"
);
fprintf
(
stderr
,
FMT
,
""
,
"If it starts with '^' it is used as an exclusion list."
);
fprintf
(
stderr
,
FMT
,
"-l"
,
"Lists the available fields to use with the -f option."
);
fprintf
(
stderr
,
FMT
,
"-n varnish_name"
,
"The varnishd instance to get logs from."
);
fprintf
(
stderr
,
FMT
,
"-N filename"
,
"Filename of a stale VSM instance."
);
fprintf
(
stderr
,
FMT
,
"-t seconds|<off>"
,
"Timeout before returning error on initial VSM connection."
);
fprintf
(
stderr
,
FMT
,
"-V"
,
"Display the version number and exit."
);
fprintf
(
stderr
,
FMT
,
"-x"
,
"Print statistics to stdout as XML."
);
fprintf
(
stderr
,
FMT
,
"-j"
,
"Print statistics to stdout as JSON."
);
#undef FMT
exit
(
1
);
const
char
**
opt
;
fprintf
(
stderr
,
"Usage: %s <options>
\n\n
"
,
progname
);
fprintf
(
stderr
,
"Options:
\n
"
);
for
(
opt
=
vopt_spec
.
vopt_usage
;
*
opt
!=
NULL
;
opt
+=
2
)
fprintf
(
stderr
,
" %-25s %s
\n
"
,
*
opt
,
*
(
opt
+
1
));
exit
(
status
);
}
int
main
(
int
argc
,
char
*
const
*
argv
)
{
int
c
;
struct
VSM_data
*
vd
;
double
t_arg
=
5
.
0
,
t_start
=
NAN
;
int
once
=
0
,
xml
=
0
,
json
=
0
,
f_list
=
0
,
curses
=
0
;
signed
char
opt
;
int
i
;
VUT_Init
(
progname
,
argc
,
argv
,
&
vopt_spec
);
vd
=
VSM_New
();
AN
(
vd
);
while
((
c
=
getopt
(
argc
,
argv
,
VSC_ARGS
"1f:lVxjt:"
))
!=
-
1
)
{
switch
(
c
)
{
while
((
opt
=
getopt
(
argc
,
argv
,
vopt_spec
.
vopt_optstring
))
!=
-
1
)
{
switch
(
opt
)
{
case
'1'
:
once
=
1
;
break
;
case
'h'
:
/* Usage help */
usage
(
0
);
case
'l'
:
f_list
=
1
;
break
;
...
...
@@ -319,10 +312,10 @@ main(int argc, char * const *argv)
json
=
1
;
break
;
default:
if
(
VSC_Arg
(
vd
,
c
,
optarg
)
>
0
)
if
(
VSC_Arg
(
vd
,
opt
,
optarg
)
>
0
)
break
;
fprintf
(
stderr
,
"%s
\n
"
,
VSM_Error
(
vd
));
usage
();
usage
(
1
);
}
}
...
...
bin/varnishstat/varnishstat_options.c
0 → 100644
View file @
fd21faff
/*-
* Copyright (c) 2016 Varnish Software AS
* All rights reserved.
*
* Author: Federico G. Schwindt <fgsch@lodoss.net>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Option definitions for varnishstat
*/
#include <stdlib.h>
#define VOPT_DEFINITION
#define VOPT_INC "varnishstat_options.h"
#include "vapi/voptget.h"
bin/varnishstat/varnishstat_options.h
0 → 100644
View file @
fd21faff
/*-
* Copyright (c) 2016 Varnish Software AS
* All rights reserved.
*
* Author: Federico G. Schwindt <fgsch@lodoss.net>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Option definitions for varnishstat
*/
#include "vapi/vapi_options.h"
#include "vut_options.h"
#define STAT_OPT_1 \
VOPT("1", "[-1]", "Print the statistics to stdout", \
"Instead of presenting a continuously updated display," \
" print the statistics to stdout." \
)
#define STAT_OPT_f \
VOPT("f:", "[-f field]", "Field inclusion glob", \
"Field inclusion glob." \
" A field glob consists of three parts, type, ident and" \
" name, where ident is optional. Each part can contain a" \
" '*' character at the end to match a prefix. Use" \
" backslash to escape characters. If the argument starts" \
" with '^' it is used as an exclusion glob. Multiple -f" \
" arguments may be given, and they will be applied in" \
" order." \
)
#define STAT_OPT_j \
VOPT("j", "[-j]", "Print statistics to stdout as JSON", \
"Print statistics to stdout as JSON." \
)
#define STAT_OPT_l \
VOPT("l", "[-l]", \
"Lists the available fields to use with the -f option", \
"Lists the available fields to use with the -f option." \
)
#define STAT_OPT_x \
VOPT("x", "[-x]", "Print statistics to stdout as XML", \
"Print statistics to stdout as XML." \
)
STAT_OPT_1
STAT_OPT_f
VUT_OPT_h
STAT_OPT_j
STAT_OPT_l
VUT_OPT_n
VUT_OPT_N
VUT_OPT_t
VUT_OPT_V
STAT_OPT_x
doc/sphinx/Makefile.am
View file @
fd21faff
...
...
@@ -164,6 +164,13 @@ include/varnishhist_synopsis.rst: $(top_builddir)/bin/varnishhist/varnishhist
BUILT_SOURCES
+=
include/varnishhist_options.rst
\
include/varnishhist_synopsis.rst
include/varnishstat_options.rst
:
$(top_builddir)/bin/varnishstat/varnishstat
$(top_builddir)
/bin/varnishstat/varnishstat
--options
>
$@
include/varnishstat_synopsis.rst
:
$(top_builddir)/bin/varnishstat/varnishstat
$(top_builddir)
/bin/varnishstat/varnishstat
--synopsis
>
$@
BUILT_SOURCES
+=
include/varnishstat_options.rst
\
include/varnishstat_synopsis.rst
include/vsl-tags.rst
:
$(top_builddir)/lib/libvarnishapi/vsl2rst
$(top_builddir)
/lib/libvarnishapi/vsl2rst
>
$@
BUILT_SOURCES
+=
include/vsl-tags.rst
...
...
doc/sphinx/reference/varnishstat.rst
View file @
fd21faff
...
...
@@ -15,60 +15,17 @@ Varnish Cache statistics
SYNOPSIS
========
varnishstat [-1] [-x] [-j] [-f field] [-l] [-n varnish_name] [-N filename] [-t seconds|<off>] [-V]
.. TODO: autogenerate this synopsis like the others.
.. include:: ../include/varnishstat_synopsis.rst
varnishstat |synopsis|
DESCRIPTION
===========
The varnishstat utility displays statistics from a running varnishd(1) instance.
OPTIONS
=======
The following options are available:
-1
Instead of presenting a continuously updated display, print
the statistics to stdout.
-f
Field inclusion glob. A field glob consists of three parts,
type, ident and name, where ident is optional. Each part can
contain a '*' character at the end to match a prefix. Use
backslash to escape characters. If the argument starts with
'^' it is used as an exclusion glob. Multiple -f arguments may
be given, and they will be applied in order.
-l
Lists the available fields to use with the -f option.
-n
Specifies the name of the varnishd instance to get logs from.
If -n is not specified, the host name is used.
-N
Specify a the filename of a stale VSM instance. When using
this option the abandonment checking is disabled.
-t seconds|<off>
Timeout before returning error on initial VSM connection. If
set the VSM connection is retried every 0.5 seconds for this
any seconds. If zero the connection is attempted only once and
will fail immediately if unsuccessful. If set to "off", the
connection will not fail, allowing the utility to start and
wait indefinitely for the Varnish instance to appear.
Defaults to 5 seconds.
-V
Display the version number and exit.
-x
Displays the result as XML.
-j
Displays the result as JSON.
.. include:: ../include/varnishstat_options.rst
CURSES MODE
===========
...
...
man/Makefile.am
View file @
fd21faff
...
...
@@ -58,8 +58,9 @@ varnishlog.1: \
$(top_builddir)/doc/sphinx/include/varnishlog_synopsis.rst
${
RST2MAN
}
$(RST2ANY_FLAGS)
$(top_srcdir)
/doc/sphinx/reference/varnishlog.rst
$@
# XXX add _options.rst and _synopsis.rst here when it's been _opt2rst'ed
varnishstat.1
:
$(top_srcdir)/doc/sphinx/reference/varnishstat.rst
varnishstat.1
:
$(top_srcdir)/doc/sphinx/reference/varnishstat.rst
\
$(top_builddir)/doc/sphinx/include/varnishstat_options.rst
\
$(top_builddir)/doc/sphinx/include/varnishstat_synopsis.rst
${
RST2MAN
}
$(RST2ANY_FLAGS)
$(top_srcdir)
/doc/sphinx/reference/varnishstat.rst
$@
varnishtest.1
:
$(top_srcdir)/doc/sphinx/reference/varnishtest.rst
...
...
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