diff --git a/include/common/uri_auth.h b/include/common/uri_auth.h index 46f1bc653..8223dc103 100644 --- a/include/common/uri_auth.h +++ b/include/common/uri_auth.h @@ -26,13 +26,6 @@ struct stat_scope { char *px_id; /* proxy id */ }; -#define ST_HIDEVER 0x00000001 /* do not report the version and reldate */ -#define ST_SHNODE 0x00000002 /* show node name */ -#define ST_SHDESC 0x00000004 /* show description */ -#define ST_SHLGNDS 0x00000008 /* show legends */ -/* unused: 0x00000010 */ -#define ST_SHOWADMIN 0x00000020 /* show the admin column */ - /* later we may link them to support multiple URI matching */ struct uri_auth { int uri_len; /* the prefix length */ @@ -40,7 +33,7 @@ struct uri_auth { char *auth_realm; /* the realm reported to the client */ char *node, *desc; /* node name & description reported in this stats */ int refresh; /* refresh interval for the browser (in seconds) */ - int flags; /* some flags describing the statistics page */ + unsigned int flags; /* STAT_* flags from stats.h and for applet.ctx.stats.flags */ struct stat_scope *scope; /* linked list of authorized proxies */ struct userlist *userlist; /* private userlist to emulate legacy "stats auth user:password" */ struct list http_req_rules; /* stats http-request rules : allow/deny/auth */ diff --git a/include/types/stats.h b/include/types/stats.h index b3a69c61d..ee16ac750 100644 --- a/include/types/stats.h +++ b/include/types/stats.h @@ -29,6 +29,13 @@ #define STAT_ADMIN 0x00000020 /* indicate a stats admin level */ #define STAT_CHUNKED 0x00000040 /* use chunked encoding (HTTP/1.1) */ #define STAT_JSON_SCHM 0x00000080 /* dump the json schema */ + +#define STAT_HIDEVER 0x00000100 /* conf: do not report the version and reldate */ +#define STAT_SHNODE 0x00000200 /* conf: show node name */ +#define STAT_SHDESC 0x00000400 /* conf: show description */ +#define STAT_SHLGNDS 0x00000800 /* conf: show legends */ +#define STAT_SHOWADMIN 0x00001000 /* conf: show the admin column */ + #define STAT_BOUND 0x00800000 /* bound statistics to selected proxies/types/services */ #define STAT_STARTED 0x01000000 /* some output has occurred */ diff --git a/src/cfgparse-listen.c b/src/cfgparse-listen.c index a5d46f593..6bece743d 100644 --- a/src/cfgparse-listen.c +++ b/src/cfgparse-listen.c @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -1874,13 +1875,13 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm) goto out; } } else if (!strcmp(args[1], "hide-version")) { - if (!stats_set_flag(&curproxy->uri_auth, ST_HIDEVER)) { + if (!stats_set_flag(&curproxy->uri_auth, STAT_HIDEVER)) { ha_alert("parsing [%s:%d] : out of memory.\n", file, linenum); err_code |= ERR_ALERT | ERR_ABORT; goto out; } } else if (!strcmp(args[1], "show-legends")) { - if (!stats_set_flag(&curproxy->uri_auth, ST_SHLGNDS)) { + if (!stats_set_flag(&curproxy->uri_auth, STAT_SHLGNDS)) { ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); err_code |= ERR_ALERT | ERR_ABORT; goto out; diff --git a/src/hlua_fcn.c b/src/hlua_fcn.c index 3b71ce1bd..28261fdcd 100644 --- a/src/hlua_fcn.c +++ b/src/hlua_fcn.c @@ -858,7 +858,7 @@ int hlua_listener_get_stats(lua_State *L) return 1; } - stats_fill_li_stats(li->bind_conf->frontend, li, ST_SHLGNDS, stats, STATS_LEN); + stats_fill_li_stats(li->bind_conf->frontend, li, STAT_SHLGNDS, stats, STATS_LEN); lua_newtable(L); for (i=0; iproxy, srv, ST_SHLGNDS, stats, STATS_LEN); + stats_fill_sv_stats(srv->proxy, srv, STAT_SHLGNDS, stats, STATS_LEN); lua_newtable(L); for (i=0; icap & PR_CAP_BE) - stats_fill_be_stats(px, ST_SHLGNDS, stats, STATS_LEN); + stats_fill_be_stats(px, STAT_SHLGNDS, stats, STATS_LEN); else stats_fill_fe_stats(px, stats, STATS_LEN); lua_newtable(L); diff --git a/src/stats.c b/src/stats.c index 64de70d18..14e5e7c30 100644 --- a/src/stats.c +++ b/src/stats.c @@ -670,8 +670,8 @@ static int stats_dump_fields_json(struct buffer *out, } /* Dump all fields from into using the HTML format. A column is - * reserved for the checkbox is ST_SHOWADMIN is set in . Some extra info - * are provided if ST_SHLGNDS is present in . + * reserved for the checkbox is STAT_SHOWADMIN is set in . Some extra info + * are provided if STAT_SHLGNDS is present in . */ static int stats_dump_fields_html(struct buffer *out, const struct field *stats, @@ -684,7 +684,7 @@ static int stats_dump_fields_html(struct buffer *out, /* name, queue */ ""); - if (flags & ST_SHOWADMIN) { + if (flags & STAT_SHOWADMIN) { /* Column sub-heading for Enable or Disable server */ chunk_appendf(out, ""); } @@ -827,7 +827,7 @@ static int stats_dump_fields_html(struct buffer *out, } else if (stats[ST_F_TYPE].u.u32 == STATS_TYPE_SO) { chunk_appendf(out, ""); - if (flags & ST_SHOWADMIN) { + if (flags & STAT_SHOWADMIN) { /* Column sub-heading for Enable or Disable server */ chunk_appendf(out, ""); } @@ -838,10 +838,10 @@ static int stats_dump_fields_html(struct buffer *out, "%s" "", field_str(stats, ST_F_PXNAME), field_str(stats, ST_F_SVNAME), - (flags & ST_SHLGNDS)?"":"", + (flags & STAT_SHLGNDS)?"":"", field_str(stats, ST_F_PXNAME), field_str(stats, ST_F_SVNAME), field_str(stats, ST_F_SVNAME)); - if (flags & ST_SHLGNDS) { + if (flags & STAT_SHLGNDS) { chunk_appendf(out, "
"); if (isdigit(*field_str(stats, ST_F_ADDR))) @@ -866,7 +866,7 @@ static int stats_dump_fields_html(struct buffer *out, /* bytes: in, out */ "%s%s" "", - (flags & ST_SHLGNDS)?"":"", + (flags & STAT_SHLGNDS)?"":"", U2H(stats[ST_F_SCUR].u.u32), U2H(stats[ST_F_SMAX].u.u32), U2H(stats[ST_F_SLIM].u.u32), U2H(stats[ST_F_STOT].u.u64), U2H(stats[ST_F_BIN].u.u64), U2H(stats[ST_F_BOUT].u.u64)); @@ -932,7 +932,7 @@ static int stats_dump_fields_html(struct buffer *out, (stats[ST_F_BCK].u.u32) ? "backup" : "active", style); - if (flags & ST_SHOWADMIN) + if (flags & STAT_SHOWADMIN) chunk_appendf(out, "", field_str(stats, ST_F_PXNAME), @@ -943,10 +943,10 @@ static int stats_dump_fields_html(struct buffer *out, "%s" "", field_str(stats, ST_F_PXNAME), field_str(stats, ST_F_SVNAME), - (flags & ST_SHLGNDS) ? "" : "", + (flags & STAT_SHLGNDS) ? "" : "", field_str(stats, ST_F_PXNAME), field_str(stats, ST_F_SVNAME), field_str(stats, ST_F_SVNAME)); - if (flags & ST_SHLGNDS) { + if (flags & STAT_SHLGNDS) { chunk_appendf(out, "
"); if (isdigit(*field_str(stats, ST_F_ADDR))) @@ -976,7 +976,7 @@ static int stats_dump_fields_html(struct buffer *out, /* sessions rate : current, max, limit */ "%s%s" "", - (flags & ST_SHLGNDS) ? "" : "", + (flags & STAT_SHLGNDS) ? "" : "", U2H(stats[ST_F_QCUR].u.u32), U2H(stats[ST_F_QMAX].u.u32), LIM2A(stats[ST_F_QLIMIT].u.u32, "-"), U2H(stats[ST_F_RATE].u.u32), U2H(stats[ST_F_RATE_MAX].u.u32)); @@ -1188,7 +1188,7 @@ static int stats_dump_fields_html(struct buffer *out, } else if (stats[ST_F_TYPE].u.u32 == STATS_TYPE_BE) { chunk_appendf(out, ""); - if (flags & ST_SHOWADMIN) { + if (flags & STAT_SHOWADMIN) { /* Column sub-heading for Enable or Disable server */ chunk_appendf(out, ""); } @@ -1198,10 +1198,10 @@ static int stats_dump_fields_html(struct buffer *out, "%s" "Backend" "", - (flags & ST_SHLGNDS)?"":"", + (flags & STAT_SHLGNDS)?"":"", field_str(stats, ST_F_PXNAME), field_str(stats, ST_F_PXNAME)); - if (flags & ST_SHLGNDS) { + if (flags & STAT_SHLGNDS) { /* balancing */ chunk_appendf(out, "
balancing: %s", field_str(stats, ST_F_ALGO)); @@ -1223,7 +1223,7 @@ static int stats_dump_fields_html(struct buffer *out, /* sessions rate : current, max, limit */ "%s%s" "", - (flags & ST_SHLGNDS)?"":"", + (flags & STAT_SHLGNDS)?"":"", U2H(stats[ST_F_QCUR].u.u32), U2H(stats[ST_F_QMAX].u.u32), U2H(stats[ST_F_RATE].u.u32), U2H(stats[ST_F_RATE_MAX].u.u32)); @@ -1357,7 +1357,7 @@ int stats_dump_one_line(const struct field *stats, unsigned int flags, struct pr int ret; if ((px->cap & PR_CAP_BE) && px->srv && (appctx->ctx.stats.flags & STAT_ADMIN)) - flags |= ST_SHOWADMIN; + flags |= STAT_SHOWADMIN; if (appctx->ctx.stats.flags & STAT_FMT_HTML) ret = stats_dump_fields_html(&trash, stats, flags); @@ -1468,7 +1468,7 @@ static int stats_dump_fe_stats(struct stream_interface *si, struct proxy *px) * preallocated array of length . The length of the array * must be at least ST_F_TOTAL_FIELDS. If this length is less * then this value, the function returns 0, otherwise, it - * returns 1. can take the value ST_SHLGNDS. + * returns 1. can take the value STAT_SHLGNDS. */ int stats_fill_li_stats(struct proxy *px, struct listener *l, int flags, struct field *stats, int len) @@ -1505,7 +1505,7 @@ int stats_fill_li_stats(struct proxy *px, struct listener *l, int flags, stats[ST_F_TYPE] = mkf_u32(FO_CONFIG|FS_SERVICE, STATS_TYPE_SO); stats[ST_F_WREW] = mkf_u64(FN_COUNTER, l->counters->failed_rewrites); - if (flags & ST_SHLGNDS) { + if (flags & STAT_SHLGNDS) { char str[INET6_ADDRSTRLEN]; int port; @@ -1583,7 +1583,7 @@ static const char *srv_hlt_st[SRV_STATS_STATE_COUNT] = { * preallocated array of length . The length of the array * must be at least ST_F_TOTAL_FIELDS. If this length is less * then this value, the function returns 0, otherwise, it - * returns 1. can take the value ST_SHLGNDS. + * returns 1. can take the value STAT_SHLGNDS. */ int stats_fill_sv_stats(struct proxy *px, struct server *sv, int flags, struct field *stats, int len) @@ -1795,7 +1795,7 @@ int stats_fill_sv_stats(struct proxy *px, struct server *sv, int flags, stats[ST_F_RTIME] = mkf_u32(FN_AVG, swrate_avg(sv->counters.d_time, TIME_STATS_SAMPLES)); stats[ST_F_TTIME] = mkf_u32(FN_AVG, swrate_avg(sv->counters.t_time, TIME_STATS_SAMPLES)); - if (flags & ST_SHLGNDS) { + if (flags & STAT_SHLGNDS) { switch (addr_to_str(&sv->addr, str, sizeof(str))) { case AF_INET: stats[ST_F_ADDR] = mkf_str(FO_CONFIG|FS_SERVICE, chunk_newstr(out)); @@ -1842,7 +1842,7 @@ static int stats_dump_sv_stats(struct stream_interface *si, struct proxy *px, in * preallocated array of length . The length of the array * must be at least ST_F_TOTAL_FIELDS. If this length is less * then this value, the function returns 0, otherwise, it - * returns 1. can take the value ST_SHLGNDS. + * returns 1. can take the value STAT_SHLGNDS. */ int stats_fill_be_stats(struct proxy *px, int flags, struct field *stats, int len) { @@ -1888,7 +1888,7 @@ int stats_fill_be_stats(struct proxy *px, int flags, struct field *stats, int le stats[ST_F_RATE] = mkf_u32(0, read_freq_ctr(&px->be_sess_per_sec)); stats[ST_F_RATE_MAX] = mkf_u32(0, px->be_counters.sps_max); - if (flags & ST_SHLGNDS) { + if (flags & STAT_SHLGNDS) { if (px->cookie_name) stats[ST_F_COOKIE] = mkf_str(FO_CONFIG|FN_NAME|FS_SERVICE, px->cookie_name); stats[ST_F_ALGO] = mkf_str(FO_CONFIG|FS_SERVICE, backend_lb_algo_str(px->lbprm.algo & BE_LB_ALGO)); @@ -1981,10 +1981,10 @@ static void stats_dump_html_px_hdr(struct stream_interface *si, struct proxy *px "%s" "%s", px->id, - (uri->flags & ST_SHLGNDS) ? "":"", + (uri->flags & STAT_SHLGNDS) ? "":"", px->id, px->id); - if (uri->flags & ST_SHLGNDS) { + if (uri->flags & STAT_SHLGNDS) { /* cap, mode, id */ chunk_appendf(&trash, "
cap: %s, mode: %s, id: %d", proxy_cap_str(px->cap), proxy_mode_str(px->mode), @@ -1999,7 +1999,7 @@ static void stats_dump_html_px_hdr(struct stream_interface *si, struct proxy *px "\n" "\n" "", - (uri->flags & ST_SHLGNDS) ? "":"", + (uri->flags & STAT_SHLGNDS) ? "":"", px->desc ? "desc" : "empty", px->desc ? px->desc : ""); if ((px->cap & PR_CAP_BE) && px->srv && (appctx->ctx.stats.flags & STAT_ADMIN)) { @@ -2089,9 +2089,9 @@ int stats_dump_proxy_to_buffer(struct stream_interface *si, struct htx *htx, if (uri) flags = uri->flags; else if ((strm_li(s)->bind_conf->level & ACCESS_LVL_MASK) >= ACCESS_LVL_OPER) - flags = ST_SHLGNDS | ST_SHNODE | ST_SHDESC; + flags = STAT_SHLGNDS | STAT_SHNODE | STAT_SHDESC; else - flags = ST_SHNODE | ST_SHDESC; + flags = STAT_SHNODE | STAT_SHDESC; chunk_reset(&trash); @@ -2386,8 +2386,8 @@ static void stats_dump_html_head(struct uri_auth *uri) "u:hover div.tips {visibility:visible;}\n" "-->\n" "\n", - (uri->flags & ST_SHNODE) ? " on " : "", - (uri->flags & ST_SHNODE) ? (uri->node ? uri->node : global.node) : "" + (uri->flags & STAT_SHNODE) ? " on " : "", + (uri->flags & STAT_SHNODE) ? (uri->node ? uri->node : global.node) : "" ); } @@ -2454,11 +2454,11 @@ static void stats_dump_html_info(struct stream_interface *si, struct uri_auth *u "
" "Display option:
    " "", - (uri->flags & ST_HIDEVER) ? "" : (stats_version_string), - pid, (uri->flags & ST_SHNODE) ? " on " : "", - (uri->flags & ST_SHNODE) ? (uri->node ? uri->node : global.node) : "", - (uri->flags & ST_SHDESC) ? ": " : "", - (uri->flags & ST_SHDESC) ? (uri->desc ? uri->desc : global.desc) : "", + (uri->flags & STAT_HIDEVER) ? "" : (stats_version_string), + pid, (uri->flags & STAT_SHNODE) ? " on " : "", + (uri->flags & STAT_SHNODE) ? (uri->node ? uri->node : global.node) : "", + (uri->flags & STAT_SHDESC) ? ": " : "", + (uri->flags & STAT_SHDESC) ? (uri->desc ? uri->desc : global.desc) : "", pid, relative_pid, global.nbproc, global.nbthread, up / 86400, (up % 86400) / 3600, (up % 3600) / 60, (up % 60), diff --git a/src/uri_auth.c b/src/uri_auth.c index dcfa5e0a7..352737a31 100644 --- a/src/uri_auth.c +++ b/src/uri_auth.c @@ -17,6 +17,7 @@ #include #include +#include #include /* @@ -108,7 +109,7 @@ struct uri_auth *stats_set_realm(struct uri_auth **root, char *realm) } /* - * Returns a default uri_auth with ST_SHNODE flag enabled and + * Returns a default uri_auth with STAT_SHNODE flag enabled and * set as the name if it is not empty. * Uses the pointer provided if not NULL and not initialized. */ @@ -126,7 +127,7 @@ struct uri_auth *stats_set_node(struct uri_auth **root, char *name) if ((u = stats_check_init_uri_auth(root)) == NULL) goto out_u; - if (!stats_set_flag(root, ST_SHNODE)) + if (!stats_set_flag(root, STAT_SHNODE)) goto out_u; if (node_copy) { @@ -143,7 +144,7 @@ struct uri_auth *stats_set_node(struct uri_auth **root, char *name) } /* - * Returns a default uri_auth with ST_SHDESC flag enabled and + * Returns a default uri_auth with STAT_SHDESC flag enabled and * set as the desc if it is not empty. * Uses the pointer provided if not NULL and not initialized. */ @@ -161,7 +162,7 @@ struct uri_auth *stats_set_desc(struct uri_auth **root, char *desc) if ((u = stats_check_init_uri_auth(root)) == NULL) goto out_u; - if (!stats_set_flag(root, ST_SHDESC)) + if (!stats_set_flag(root, STAT_SHDESC)) goto out_u; if (desc_copy) {