Commit c810670f authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

More wanton renaming, this time varnishapi::VSC



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4935 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 5d2f3bcf
...@@ -52,7 +52,7 @@ SVNID("$Id$") ...@@ -52,7 +52,7 @@ SVNID("$Id$")
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static int static int
do_xml_cb(void *priv, const struct vsl_statpt * const pt) do_xml_cb(void *priv, const struct vsc_point * const pt)
{ {
uint64_t val; uint64_t val;
...@@ -83,7 +83,7 @@ do_xml(const struct VSM_data *vd) ...@@ -83,7 +83,7 @@ do_xml(const struct VSM_data *vd)
now = time(NULL); now = time(NULL);
(void)strftime(time_stamp, 20, "%Y-%m-%dT%H:%M:%S", localtime(&now)); (void)strftime(time_stamp, 20, "%Y-%m-%dT%H:%M:%S", localtime(&now));
printf("<varnishstat timestamp=\"%s\">\n", time_stamp); printf("<varnishstat timestamp=\"%s\">\n", time_stamp);
(void)VSL_IterStat(vd, do_xml_cb, NULL); (void)VSC_Iter(vd, do_xml_cb, NULL);
printf("</varnishstat>\n"); printf("</varnishstat>\n");
} }
...@@ -95,7 +95,7 @@ struct once_priv { ...@@ -95,7 +95,7 @@ struct once_priv {
}; };
static int static int
do_once_cb(void *priv, const struct vsl_statpt * const pt) do_once_cb(void *priv, const struct vsc_point * const pt)
{ {
struct once_priv *op; struct once_priv *op;
uint64_t val; uint64_t val;
...@@ -129,13 +129,13 @@ do_once(const struct VSM_data *vd, const struct vsc_main *VSL_stats) ...@@ -129,13 +129,13 @@ do_once(const struct VSM_data *vd, const struct vsc_main *VSL_stats)
op.up = VSL_stats->uptime; op.up = VSL_stats->uptime;
op.pad = 18; op.pad = 18;
(void)VSL_IterStat(vd, do_once_cb, &op); (void)VSC_Iter(vd, do_once_cb, &op);
} }
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static int static int
do_list_cb(void *priv, const struct vsl_statpt * const pt) do_list_cb(void *priv, const struct vsc_point * const pt)
{ {
int i; int i;
...@@ -159,7 +159,7 @@ list_fields(const struct VSM_data *vd) ...@@ -159,7 +159,7 @@ list_fields(const struct VSM_data *vd)
fprintf(stderr, "Field name Description\n"); fprintf(stderr, "Field name Description\n");
fprintf(stderr, "---------- -----------\n"); fprintf(stderr, "---------- -----------\n");
(void)VSL_IterStat(vd, do_list_cb, NULL); (void)VSC_Iter(vd, do_list_cb, NULL);
} }
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
...@@ -204,7 +204,7 @@ main(int argc, char * const *argv) ...@@ -204,7 +204,7 @@ main(int argc, char * const *argv)
once = 1; once = 1;
break; break;
case 'f': case 'f':
(void)VSL_Stat_Arg(vd, c, optarg); (void)VSC_Arg(vd, c, optarg);
break; break;
case 'l': case 'l':
if (VSM_Open(vd, 1)) if (VSM_Open(vd, 1))
...@@ -221,7 +221,7 @@ main(int argc, char * const *argv) ...@@ -221,7 +221,7 @@ main(int argc, char * const *argv)
xml = 1; xml = 1;
break; break;
default: default:
if (VSL_Stat_Arg(vd, c, optarg) > 0) if (VSC_Arg(vd, c, optarg) > 0)
break; break;
usage(); usage();
} }
......
...@@ -66,7 +66,7 @@ struct pt { ...@@ -66,7 +66,7 @@ struct pt {
static VTAILQ_HEAD(, pt) pthead = VTAILQ_HEAD_INITIALIZER(pthead); static VTAILQ_HEAD(, pt) pthead = VTAILQ_HEAD_INITIALIZER(pthead);
static int static int
do_curses_cb(void *priv, const struct vsl_statpt * const sp) do_curses_cb(void *priv, const struct vsc_point * const sp)
{ {
struct pt *pt; struct pt *pt;
char buf[128]; char buf[128];
...@@ -110,7 +110,7 @@ prep_pts(const struct VSM_data *vd) ...@@ -110,7 +110,7 @@ prep_pts(const struct VSM_data *vd)
free(pt); free(pt);
} }
(void)VSL_IterStat(vd, do_curses_cb, NULL); (void)VSC_Iter(vd, do_curses_cb, NULL);
} }
static void static void
......
...@@ -607,7 +607,7 @@ struct stat_priv { ...@@ -607,7 +607,7 @@ struct stat_priv {
}; };
static int static int
do_stat_cb(void *priv, const struct vsl_statpt * const pt) do_stat_cb(void *priv, const struct vsc_point * const pt)
{ {
struct stat_priv *sp = priv; struct stat_priv *sp = priv;
const char *p = sp->target; const char *p = sp->target;
...@@ -655,7 +655,7 @@ varnish_expect(const struct varnish *v, char * const *av) { ...@@ -655,7 +655,7 @@ varnish_expect(const struct varnish *v, char * const *av) {
for (i = 0; i < 10; i++, (void)usleep(100000)) { for (i = 0; i < 10; i++, (void)usleep(100000)) {
good = -1; good = -1;
if (!VSL_IterStat(v->vd, do_stat_cb, &sp)) if (!VSC_Iter(v->vd, do_stat_cb, &sp))
continue; continue;
good = 0; good = 0;
......
...@@ -68,7 +68,7 @@ int VSM_n_Arg(struct VSM_data *vd, const char *n_arg); ...@@ -68,7 +68,7 @@ int VSM_n_Arg(struct VSM_data *vd, const char *n_arg);
/* /*
* Configure which varnishd instance to access. * Configure which varnishd instance to access.
* Can also be, and normally is done through the VSL_Log_arg() * Can also be, and normally is done through the VSL_Log_arg()
* and VSL_Stat_Arg() functions. * and VSC_Arg() functions.
* Returns: * Returns:
* 1 on success * 1 on success
* -1 on failure, with diagnostic on stderr. * -1 on failure, with diagnostic on stderr.
...@@ -121,6 +121,30 @@ void vsm_itern(const struct VSM_data *vd, struct vsm_chunk **pp); ...@@ -121,6 +121,30 @@ void vsm_itern(const struct VSM_data *vd, struct vsm_chunk **pp);
#define VSM_FOREACH(var, vd) \ #define VSM_FOREACH(var, vd) \
for((var) = vsm_iter0((vd)); (var) != NULL; vsm_itern((vd), &(var))) for((var) = vsm_iter0((vd)); (var) != NULL; vsm_itern((vd), &(var)))
/*---------------------------------------------------------------------
* VSC level access functions
*/
int VSC_Arg(struct VSM_data *vd, int arg, const char *opt);
struct vsc_main *VSM_OpenStats(struct VSM_data *vd);
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 volatile void *ptr; /* field value */
};
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);
/*---------------------------------------------------------------------
* VSL level access functions
*/
/* shmlog.c */ /* shmlog.c */
typedef int vsl_handler(void *priv, enum vsl_tag tag, unsigned fd, typedef int vsl_handler(void *priv, enum vsl_tag tag, unsigned fd,
...@@ -139,25 +163,9 @@ void VSL_NonBlocking(struct VSM_data *vd, int nb); ...@@ -139,25 +163,9 @@ void VSL_NonBlocking(struct VSM_data *vd, int nb);
int VSL_Dispatch(struct VSM_data *vd, vsl_handler *func, void *priv); int VSL_Dispatch(struct VSM_data *vd, vsl_handler *func, void *priv);
int VSL_NextLog(struct VSM_data *lh, uint32_t **pp); int VSL_NextLog(struct VSM_data *lh, uint32_t **pp);
int VSL_Log_Arg(struct VSM_data *vd, int arg, const char *opt); int VSL_Log_Arg(struct VSM_data *vd, int arg, const char *opt);
int VSL_Stat_Arg(struct VSM_data *vd, int arg, const char *opt);
struct vsc_main *VSM_OpenStats(struct VSM_data *vd);
extern const char *VSL_tags[256]; extern const char *VSL_tags[256];
struct vsl_statpt {
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 volatile void *ptr; /* field value */
};
typedef int vsl_stat_f(void *priv, const struct vsl_statpt *const pt);
int VSL_IterStat(const struct VSM_data *vd, vsl_stat_f *func, void *priv);
/* base64.c */ /* base64.c */
void base64_init(void); void base64_init(void);
int base64_decode(char *d, unsigned dlen, const char *s); int base64_decode(char *d, unsigned dlen, const char *s);
......
...@@ -35,11 +35,14 @@ SVNID("$Id$") ...@@ -35,11 +35,14 @@ SVNID("$Id$")
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <string.h> #include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "vas.h" #include "vas.h"
#include "vsm.h" #include "vsm.h"
#include "vsc.h" #include "vsc.h"
#include "vre.h" #include "vre.h"
#include "argv.h"
#include "vqueue.h" #include "vqueue.h"
#include "miniobj.h" #include "miniobj.h"
#include "varnishapi.h" #include "varnishapi.h"
...@@ -48,6 +51,101 @@ SVNID("$Id$") ...@@ -48,6 +51,101 @@ SVNID("$Id$")
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static int
vsc_sf_arg(struct VSM_data *vd, const char *opt)
{
struct vsl_sf *sf;
char **av, *q, *p;
int i;
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
if (VTAILQ_EMPTY(&vd->sf_list)) {
if (*opt == '^')
vd->sf_init = 1;
}
av = ParseArgv(opt, ARGV_COMMA);
AN(av);
if (av[0] != NULL) {
fprintf(stderr, "Parse error: %s", av[0]);
exit (1);
}
for (i = 1; av[i] != NULL; i++) {
ALLOC_OBJ(sf, VSL_SF_MAGIC);
AN(sf);
VTAILQ_INSERT_TAIL(&vd->sf_list, sf, next);
p = av[i];
if (*p == '^') {
sf->flags |= VSL_SF_EXCL;
p++;
}
q = strchr(p, '.');
if (q != NULL) {
*q++ = '\0';
if (*p != '\0')
REPLACE(sf->class, p);
p = q;
if (*p != '\0') {
q = strchr(p, '.');
if (q != NULL) {
*q++ = '\0';
if (*p != '\0')
REPLACE(sf->ident, p);
p = q;
}
}
}
if (*p != '\0') {
REPLACE(sf->name, p);
}
/* Check for wildcards */
if (sf->class != NULL) {
q = strchr(sf->class, '*');
if (q != NULL && q[1] == '\0') {
*q = '\0';
sf->flags |= VSL_SF_CL_WC;
}
}
if (sf->ident != NULL) {
q = strchr(sf->ident, '*');
if (q != NULL && q[1] == '\0') {
*q = '\0';
sf->flags |= VSL_SF_ID_WC;
}
}
if (sf->name != NULL) {
q = strchr(sf->name, '*');
if (q != NULL && q[1] == '\0') {
*q = '\0';
sf->flags |= VSL_SF_NM_WC;
}
}
}
FreeArgv(av);
return (1);
}
/*--------------------------------------------------------------------*/
int
VSC_Arg(struct VSM_data *vd, int arg, const char *opt)
{
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
switch (arg) {
case 'f': return (vsc_sf_arg(vd, opt));
case 'n': return (VSM_n_Arg(vd, opt));
default:
return (0);
}
}
/*--------------------------------------------------------------------*/
struct vsc_main * struct vsc_main *
VSM_OpenStats(struct VSM_data *vd) VSM_OpenStats(struct VSM_data *vd)
{ {
...@@ -78,8 +176,8 @@ iter_test(const char *s1, const char *s2, int wc) ...@@ -78,8 +176,8 @@ iter_test(const char *s1, const char *s2, int wc)
} }
static int static int
iter_call(const struct VSM_data *vd, vsl_stat_f *func, void *priv, iter_call(const struct VSM_data *vd, vsc_iter_f *func, void *priv,
const struct vsl_statpt *const sp) const struct vsc_point *const sp)
{ {
struct vsl_sf *sf; struct vsl_sf *sf;
int good = vd->sf_init; int good = vd->sf_init;
...@@ -105,11 +203,11 @@ iter_call(const struct VSM_data *vd, vsl_stat_f *func, void *priv, ...@@ -105,11 +203,11 @@ iter_call(const struct VSM_data *vd, vsl_stat_f *func, void *priv,
} }
static int static int
iter_main(const struct VSM_data *vd, struct vsm_chunk *sha, vsl_stat_f *func, iter_main(const struct VSM_data *vd, struct vsm_chunk *sha, vsc_iter_f *func,
void *priv) void *priv)
{ {
struct vsc_main *st = VSM_PTR(sha); struct vsc_main *st = VSM_PTR(sha);
struct vsl_statpt sp; struct vsc_point sp;
int i; int i;
sp.class = ""; sp.class = "";
...@@ -129,11 +227,11 @@ iter_main(const struct VSM_data *vd, struct vsm_chunk *sha, vsl_stat_f *func, ...@@ -129,11 +227,11 @@ iter_main(const struct VSM_data *vd, struct vsm_chunk *sha, vsl_stat_f *func,
} }
static int static int
iter_sma(const struct VSM_data *vd, struct vsm_chunk *sha, vsl_stat_f *func, iter_sma(const struct VSM_data *vd, struct vsm_chunk *sha, vsc_iter_f *func,
void *priv) void *priv)
{ {
struct vsc_sma *st = VSM_PTR(sha); struct vsc_sma *st = VSM_PTR(sha);
struct vsl_statpt sp; struct vsc_point sp;
int i; int i;
sp.class = VSC_TYPE_SMA; sp.class = VSC_TYPE_SMA;
...@@ -153,7 +251,7 @@ iter_sma(const struct VSM_data *vd, struct vsm_chunk *sha, vsl_stat_f *func, ...@@ -153,7 +251,7 @@ iter_sma(const struct VSM_data *vd, struct vsm_chunk *sha, vsl_stat_f *func,
} }
int int
VSL_IterStat(const struct VSM_data *vd, vsl_stat_f *func, void *priv) VSC_Iter(const struct VSM_data *vd, vsc_iter_f *func, void *priv)
{ {
struct vsm_chunk *sha; struct vsm_chunk *sha;
int i; int i;
......
...@@ -225,98 +225,3 @@ VSL_Log_Arg(struct VSM_data *vd, int arg, const char *opt) ...@@ -225,98 +225,3 @@ VSL_Log_Arg(struct VSM_data *vd, int arg, const char *opt)
return (0); return (0);
} }
} }
/*--------------------------------------------------------------------*/
static int
vsl_sf_arg(struct VSM_data *vd, const char *opt)
{
struct vsl_sf *sf;
char **av, *q, *p;
int i;
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
if (VTAILQ_EMPTY(&vd->sf_list)) {
if (*opt == '^')
vd->sf_init = 1;
}
av = ParseArgv(opt, ARGV_COMMA);
AN(av);
if (av[0] != NULL) {
fprintf(stderr, "Parse error: %s", av[0]);
exit (1);
}
for (i = 1; av[i] != NULL; i++) {
ALLOC_OBJ(sf, VSL_SF_MAGIC);
AN(sf);
VTAILQ_INSERT_TAIL(&vd->sf_list, sf, next);
p = av[i];
if (*p == '^') {
sf->flags |= VSL_SF_EXCL;
p++;
}
q = strchr(p, '.');
if (q != NULL) {
*q++ = '\0';
if (*p != '\0')
REPLACE(sf->class, p);
p = q;
if (*p != '\0') {
q = strchr(p, '.');
if (q != NULL) {
*q++ = '\0';
if (*p != '\0')
REPLACE(sf->ident, p);
p = q;
}
}
}
if (*p != '\0') {
REPLACE(sf->name, p);
}
/* Check for wildcards */
if (sf->class != NULL) {
q = strchr(sf->class, '*');
if (q != NULL && q[1] == '\0') {
*q = '\0';
sf->flags |= VSL_SF_CL_WC;
}
}
if (sf->ident != NULL) {
q = strchr(sf->ident, '*');
if (q != NULL && q[1] == '\0') {
*q = '\0';
sf->flags |= VSL_SF_ID_WC;
}
}
if (sf->name != NULL) {
q = strchr(sf->name, '*');
if (q != NULL && q[1] == '\0') {
*q = '\0';
sf->flags |= VSL_SF_NM_WC;
}
}
}
FreeArgv(av);
return (1);
}
/*--------------------------------------------------------------------*/
int
VSL_Stat_Arg(struct VSM_data *vd, int arg, const char *opt)
{
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
switch (arg) {
case 'f': return (vsl_sf_arg(vd, opt));
case 'n': return (VSM_n_Arg(vd, opt));
default:
return (0);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment