src/dumpstats.c
static int stats_dump_stat_to_buffer(struct stream_interface *si, struct uri_auth *uri)
{
	struct channel *rep = si->ib;
	struct proxy *px;

	chunk_reset(&trash);

	switch (si->conn->xprt_st) {
	case STAT_ST_INIT:
		si->conn->xprt_st = STAT_ST_HEAD; /* let's start producing data */
		/* fall through */

	case STAT_ST_HEAD:
		if (si->applet.ctx.stats.flags & STAT_FMT_HTML)
			stats_dump_html_head(uri);
		else
			stats_dump_csv_header();

		if (bi_putchk(rep, &trash) == -1)
			return 0;

		si->conn->xprt_st = STAT_ST_INFO;
		/* fall through */

	case STAT_ST_INFO:
		if (si->applet.ctx.stats.flags & STAT_FMT_HTML) {
			stats_dump_html_info(si, uri);
			if (bi_putchk(rep, &trash) == -1)
				return 0;
		}

		si->applet.ctx.stats.px = proxy;
		si->applet.ctx.stats.px_st = STAT_PX_ST_INIT;
		si->conn->xprt_st = STAT_ST_LIST;
		/* fall through */

	case STAT_ST_LIST:
		/* dump proxies */
		while (si->applet.ctx.stats.px) {
			if (buffer_almost_full(rep->buf))
				return 0;

			px = si->applet.ctx.stats.px;
			/* 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, px, uri) == 0)
					return 0;

			si->applet.ctx.stats.px = px->next;
			si->applet.ctx.stats.px_st = STAT_PX_ST_INIT;
		}
		/* here, we just have reached the last proxy */

		si->conn->xprt_st = STAT_ST_END;
		/* fall through */

	case STAT_ST_END:
		if (si->applet.ctx.stats.flags & STAT_FMT_HTML) {
			stats_dump_html_end();
			if (bi_putchk(rep, &trash) == -1)
				return 0;
		}

		si->conn->xprt_st = STAT_ST_FIN;
		/* fall through */

	case STAT_ST_FIN:
		return 1;

	default:
		/* unknown state ! */
		si->conn->xprt_st = STAT_ST_FIN;
		return -1;
	}
}
/* This function dumps statistics onto the stream interface's read buffer in
 * either CSV or HTML format. <uri> contains some HTML-specific parameters that
 * are ignored for CSV format (hence <uri> may be NULL there). The xprt_ctx must
 * have been zeroed first, and the flags properly set. It returns 0 if it had to
 * stop writing data and an I/O is needed, 1 if the dump is finished and the
 * session must be closed, or -1 in case of any error. This function is used by
 * both the CLI and the HTTP handlers.
 */
This function dumps statistics onto the stream interface's read buffer in
either CSV or HTML format.  contains some HTML-specific parameters that
are ignored for CSV format (hence  may be NULL there). The xprt_ctx must
have been zeroed first, and the flags properly set. It returns 0 if it had to
stop writing data and an I/O is needed, 1 if the dump is finished and the
session must be closed, or -1 in case of any error. This function is used by
both the CLI and the HTTP handlers.
This function dumps statistics onto the stream interface ' s read buffer in either CSV or HTML format . contains some HTML - specific parameters that are ignored for CSV format ( hence may be NULL there ) . The xprt_ctx must have been zeroed first and the flags properly set . It returns 0 if it had to stop writing data and an I / O is needed 1 if the dump is finished and the session must be closed or - 1 in case of any error . This function is used by both the CLI and the HTTP handlers .
static int stats_dump_stat_to_buffer(struct stream_interface *si, struct uri_auth *uri)
{
	struct channel *rep = si->ib;
	struct proxy *px;
	chunk_reset(&trash);
	switch (si->conn->xprt_st) {
	case STAT_ST_INIT:
		si->conn->xprt_st = STAT_ST_HEAD; 
	case STAT_ST_HEAD:
		if (si->applet.ctx.stats.flags & STAT_FMT_HTML)
			stats_dump_html_head(uri);
		else
			stats_dump_csv_header();
		if (bi_putchk(rep, &trash) == -1)
			return 0;
		si->conn->xprt_st = STAT_ST_INFO;
	case STAT_ST_INFO:
		if (si->applet.ctx.stats.flags & STAT_FMT_HTML) {
			stats_dump_html_info(si, uri);
			if (bi_putchk(rep, &trash) == -1)
				return 0;
		}
		si->applet.ctx.stats.px = proxy;
		si->applet.ctx.stats.px_st = STAT_PX_ST_INIT;
		si->conn->xprt_st = STAT_ST_LIST;
	case STAT_ST_LIST:
		while (si->applet.ctx.stats.px) {
			if (buffer_almost_full(rep->buf))
				return 0;
			px = si->applet.ctx.stats.px;
			if (px->state != PR_STSTOPPED && px->uuid > 0 && (px->cap & (PR_CAP_FE | PR_CAP_BE)))
				if (stats_dump_proxy_to_buffer(si, px, uri) == 0)
					return 0;
			si->applet.ctx.stats.px = px->next;
			si->applet.ctx.stats.px_st = STAT_PX_ST_INIT;
		}
		si->conn->xprt_st = STAT_ST_END;
	case STAT_ST_END:
		if (si->applet.ctx.stats.flags & STAT_FMT_HTML) {
			stats_dump_html_end();
			if (bi_putchk(rep, &trash) == -1)
				return 0;
		}
		si->conn->xprt_st = STAT_ST_FIN;
	case STAT_ST_FIN:
		return 1;
	default:
		si->conn->xprt_st = STAT_ST_FIN;
		return -1;
	}
}
static int stats_dump_stat_to_buffer ( struct stream_interface * si , struct uri_auth * uri ) { struct channel * rep = si -> ib ; struct proxy * px ; chunk_reset ( & trash ) ; switch ( si -> conn -> xprt_st ) { case STAT_ST_INIT : si -> conn -> xprt_st = STAT_ST_HEAD ; case STAT_ST_HEAD : if ( si -> applet . ctx . stats . flags & STAT_FMT_HTML ) stats_dump_html_head ( uri ) ; else stats_dump_csv_header ( ) ; if ( bi_putchk ( rep , & trash ) == -1 ) return 0 ; si -> conn -> xprt_st = STAT_ST_INFO ; case STAT_ST_INFO : if ( si -> applet . ctx . stats . flags & STAT_FMT_HTML ) { stats_dump_html_info ( si , uri ) ; if ( bi_putchk ( rep , & trash ) == -1 ) return 0 ; } si -> applet . ctx . stats . px = proxy ; si -> applet . ctx . stats . px_st = STAT_PX_ST_INIT ; si -> conn -> xprt_st = STAT_ST_LIST ; case STAT_ST_LIST : while ( si -> applet . ctx . stats . px ) { if ( buffer_almost_full ( rep -> buf ) ) return 0 ; px = si -> applet . ctx . stats . px ; if ( px -> state != PR_STSTOPPED && px -> uuid > 0 && ( px -> cap & ( PR_CAP_FE | PR_CAP_BE ) ) ) if ( stats_dump_proxy_to_buffer ( si , px , uri ) == 0 ) return 0 ; si -> applet . ctx . stats . px = px -> next ; si -> applet . ctx . stats . px_st = STAT_PX_ST_INIT ; } si -> conn -> xprt_st = STAT_ST_END ; case STAT_ST_END : if ( si -> applet . ctx . stats . flags & STAT_FMT_HTML ) { stats_dump_html_end ( ) ; if ( bi_putchk ( rep , & trash ) == -1 ) return 0 ; } si -> conn -> xprt_st = STAT_ST_FIN ; case STAT_ST_FIN : return 1 ; default : si -> conn -> xprt_st = STAT_ST_FIN ; return -1 ; } }
This function dumps statistics onto the stream interface's read buffer in
 either CSV or HTML format.
This function dumps statistics onto the stream interface ' s read buffer in either CSV or HTML format .
/* let's start producing data */ /* fall through */ /* fall through */ /* fall through */ /* dump proxies */ /* skip the disabled proxies, global frontend and non-networked ones */ /* here, we just have reached the last proxy */ /* fall through */ /* fall through */ /* unknown state ! */