goto full;
}
else {
- struct proxy *px = appctx->ctx.stats.px;
- struct server *srv = appctx->ctx.stats.sv;
+ struct proxy *px = appctx->ctx.stats.obj1;
+ struct server *srv = appctx->ctx.stats.obj2;
const struct ist label = promex_st_metric_labels[appctx->st2];
if (istcat(out, name, max) == -1 ||
int ret = 1;
while (appctx->st2 && appctx->st2 < ST_F_TOTAL_FIELDS) {
- while (appctx->ctx.stats.px) {
- px = appctx->ctx.stats.px;
+ while (appctx->ctx.stats.obj1) {
+ px = appctx->ctx.stats.obj1;
/* skip the disabled proxies, global frontend and non-networked ones */
if (px->state == PR_STSTOPPED || px->uuid <= 0 || !(px->cap & PR_CAP_FE))
if (!promex_dump_metric(appctx, htx, prefix, &metric, &out, max))
goto full;
next_px:
- appctx->ctx.stats.px = px->next;
+ appctx->ctx.stats.obj1 = px->next;
}
next_metric:
appctx->ctx.stats.flags |= PROMEX_FL_METRIC_HDR;
- appctx->ctx.stats.px = proxies_list;
+ appctx->ctx.stats.obj1 = proxies_list;
appctx->st2 = promex_front_metrics[appctx->st2];
}
double secs;
while (appctx->st2 && appctx->st2 < ST_F_TOTAL_FIELDS) {
- while (appctx->ctx.stats.px) {
- px = appctx->ctx.stats.px;
+ while (appctx->ctx.stats.obj1) {
+ px = appctx->ctx.stats.obj1;
/* skip the disabled proxies, global frontend and non-networked ones */
if (px->state == PR_STSTOPPED || px->uuid <= 0 || !(px->cap & PR_CAP_BE))
if (!promex_dump_metric(appctx, htx, prefix, &metric, &out, max))
goto full;
next_px:
- appctx->ctx.stats.px = px->next;
+ appctx->ctx.stats.obj1 = px->next;
}
next_metric:
appctx->ctx.stats.flags |= PROMEX_FL_METRIC_HDR;
- appctx->ctx.stats.px = proxies_list;
+ appctx->ctx.stats.obj1 = proxies_list;
appctx->st2 = promex_back_metrics[appctx->st2];
}
double secs;
while (appctx->st2 && appctx->st2 < ST_F_TOTAL_FIELDS) {
- while (appctx->ctx.stats.px) {
- px = appctx->ctx.stats.px;
+ while (appctx->ctx.stats.obj1) {
+ px = appctx->ctx.stats.obj1;
/* skip the disabled proxies, global frontend and non-networked ones */
if (px->state == PR_STSTOPPED || px->uuid <= 0 || !(px->cap & PR_CAP_BE))
goto next_px;
- while (appctx->ctx.stats.sv) {
- sv = appctx->ctx.stats.sv;
+ while (appctx->ctx.stats.obj2) {
+ sv = appctx->ctx.stats.obj2;
if ((appctx->ctx.stats.flags & PROMEX_FL_NO_MAINT_SRV) && (sv->cur_admin & SRV_ADMF_MAINT))
goto next_sv;
goto full;
next_sv:
- appctx->ctx.stats.sv = sv->next;
+ appctx->ctx.stats.obj2 = sv->next;
}
next_px:
- appctx->ctx.stats.px = px->next;
- appctx->ctx.stats.sv = (appctx->ctx.stats.px ? appctx->ctx.stats.px->srv : NULL);
+ appctx->ctx.stats.obj1 = px->next;
+ appctx->ctx.stats.obj2 = (appctx->ctx.stats.obj1 ? ((struct proxy *)appctx->ctx.stats.obj1)->srv : NULL);
}
next_metric:
appctx->ctx.stats.flags |= PROMEX_FL_METRIC_HDR;
- appctx->ctx.stats.px = proxies_list;
- appctx->ctx.stats.sv = (appctx->ctx.stats.px ? appctx->ctx.stats.px->srv : NULL);
+ appctx->ctx.stats.obj1 = proxies_list;
+ appctx->ctx.stats.obj2 = (appctx->ctx.stats.obj1 ? ((struct proxy *)appctx->ctx.stats.obj1)->srv : NULL);
appctx->st2 = promex_srv_metrics[appctx->st2];
}
/* Dump all metrics (global, frontends, backends and servers) depending on the
* dumper state (appctx->st1). It returns 1 on success, 0 if <htx> is full and
- * -1 in case of any error. */
+ * -1 in case of any error.
+ * Uses <appctx.ctx.stats.obj1> as a pointer to the current proxy and <obj2> as
+ * a pointer to the current server/listener. */
static int promex_dump_metrics(struct appctx *appctx, struct stream_interface *si, struct htx *htx)
{
int ret;
switch (appctx->st1) {
case PROMEX_DUMPER_INIT:
- appctx->ctx.stats.px = NULL;
- appctx->ctx.stats.sv = NULL;
+ appctx->ctx.stats.obj1 = NULL;
+ appctx->ctx.stats.obj2 = NULL;
appctx->ctx.stats.flags |= (PROMEX_FL_METRIC_HDR|PROMEX_FL_INFO_METRIC);
appctx->st2 = promex_global_metrics[INF_NAME];
appctx->st1 = PROMEX_DUMPER_GLOBAL;
}
}
- appctx->ctx.stats.px = proxies_list;
- appctx->ctx.stats.sv = NULL;
+ appctx->ctx.stats.obj1 = proxies_list;
+ appctx->ctx.stats.obj2 = NULL;
appctx->ctx.stats.flags &= ~PROMEX_FL_INFO_METRIC;
appctx->ctx.stats.flags |= (PROMEX_FL_METRIC_HDR|PROMEX_FL_STATS_METRIC);
appctx->st2 = promex_front_metrics[ST_F_PXNAME];
}
}
- appctx->ctx.stats.px = proxies_list;
- appctx->ctx.stats.sv = NULL;
+ appctx->ctx.stats.obj1 = proxies_list;
+ appctx->ctx.stats.obj2 = NULL;
appctx->ctx.stats.flags |= PROMEX_FL_METRIC_HDR;
appctx->st2 = promex_back_metrics[ST_F_PXNAME];
appctx->st1 = PROMEX_DUMPER_BACK;
}
}
- appctx->ctx.stats.px = proxies_list;
- appctx->ctx.stats.sv = (appctx->ctx.stats.px ? appctx->ctx.stats.px->srv : NULL);
+ appctx->ctx.stats.obj1 = proxies_list;
+ appctx->ctx.stats.obj2 = (appctx->ctx.stats.obj1 ? ((struct proxy *)appctx->ctx.stats.obj1)->srv : NULL);
appctx->ctx.stats.flags |= PROMEX_FL_METRIC_HDR;
appctx->st2 = promex_srv_metrics[ST_F_PXNAME];
appctx->st1 = PROMEX_DUMPER_SRV;
}
}
- appctx->ctx.stats.px = NULL;
- appctx->ctx.stats.sv = NULL;
+ appctx->ctx.stats.obj1 = NULL;
+ appctx->ctx.stats.obj2 = NULL;
appctx->ctx.stats.flags &= ~(PROMEX_FL_METRIC_HDR|PROMEX_FL_INFO_METRIC|PROMEX_FL_STATS_METRIC);
appctx->st2 = 0;
appctx->st1 = PROMEX_DUMPER_DONE;
return 0;
error:
/* unrecoverable error */
- appctx->ctx.stats.px = NULL;
- appctx->ctx.stats.sv = NULL;
+ appctx->ctx.stats.obj1 = NULL;
+ appctx->ctx.stats.obj2 = NULL;
appctx->ctx.stats.flags = 0;
appctx->st2 = 0;
appctx->st1 = PROMEX_DUMPER_DONE;
goto full;
}
- appctx->ctx.stats.l = px->conf.listeners.n;
+ appctx->ctx.stats.obj2 = px->conf.listeners.n;
appctx->ctx.stats.px_st = STAT_PX_ST_LI;
/* fall through */
case STAT_PX_ST_LI:
- /* stats.l has been initialized above */
- for (; appctx->ctx.stats.l != &px->conf.listeners; appctx->ctx.stats.l = l->by_fe.n) {
+ /* obj2 points to listeners list as initialized above */
+ for (; appctx->ctx.stats.obj2 != &px->conf.listeners; appctx->ctx.stats.obj2 = l->by_fe.n) {
if (htx) {
if (htx_almost_full(htx))
goto full;
goto full;
}
- l = LIST_ELEM(appctx->ctx.stats.l, struct listener *, by_fe);
+ l = LIST_ELEM(appctx->ctx.stats.obj2, struct listener *, by_fe);
if (!l->counters)
continue;
}
}
- appctx->ctx.stats.sv = px->srv; /* may be NULL */
+ appctx->ctx.stats.obj2 = px->srv; /* may be NULL */
appctx->ctx.stats.px_st = STAT_PX_ST_SV;
/* fall through */
case STAT_PX_ST_SV:
- /* stats.sv has been initialized above */
- for (; appctx->ctx.stats.sv != NULL; appctx->ctx.stats.sv = sv->next) {
+ /* obj2 points to servers list as initialized above */
+ for (; appctx->ctx.stats.obj2 != NULL; appctx->ctx.stats.obj2 = sv->next) {
if (htx) {
if (htx_almost_full(htx))
goto full;
goto full;
}
- sv = appctx->ctx.stats.sv;
+ sv = appctx->ctx.stats.obj2;
if (appctx->ctx.stats.flags & STAT_BOUND) {
if (!(appctx->ctx.stats.type & (1 << STATS_TYPE_SV)))
goto full;
}
- appctx->ctx.stats.px = proxies_list;
+ appctx->ctx.stats.obj1 = proxies_list;
appctx->ctx.stats.px_st = STAT_PX_ST_INIT;
appctx->st2 = STAT_ST_LIST;
/* fall through */
case STAT_ST_LIST:
/* dump proxies */
- while (appctx->ctx.stats.px) {
+ while (appctx->ctx.stats.obj1) {
if (htx) {
if (htx_almost_full(htx))
goto full;
goto full;
}
- px = appctx->ctx.stats.px;
+ px = appctx->ctx.stats.obj1;
/* skip the disabled proxies, global frontend and non-networked ones */
if (px->state != PR_STSTOPPED && px->uuid > 0 && (px->cap & (PR_CAP_FE | PR_CAP_BE)))
if (stats_dump_proxy_to_buffer(si, htx, px, uri) == 0)
return 0;
- appctx->ctx.stats.px = px->next;
+ appctx->ctx.stats.obj1 = px->next;
appctx->ctx.stats.px_st = STAT_PX_ST_INIT;
}
/* here, we just have reached the last proxy */