2007-10-17 15:06:05 +00:00
|
|
|
/*
|
2010-05-28 16:46:57 +00:00
|
|
|
* include/proto/dumpstats.h
|
|
|
|
* This file contains definitions of some primitives to dedicated to
|
|
|
|
* statistics output.
|
|
|
|
*
|
2011-02-13 12:16:36 +00:00
|
|
|
* Copyright (C) 2000-2011 Willy Tarreau - w@1wt.eu
|
2010-05-28 16:46:57 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation, version 2.1
|
|
|
|
* exclusively.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2007-10-17 15:06:05 +00:00
|
|
|
|
|
|
|
#ifndef _PROTO_DUMPSTATS_H
|
|
|
|
#define _PROTO_DUMPSTATS_H
|
|
|
|
|
|
|
|
#include <common/config.h>
|
2015-04-13 11:24:54 +00:00
|
|
|
#include <types/applet.h>
|
2012-08-24 17:22:53 +00:00
|
|
|
#include <types/stream_interface.h>
|
2007-10-17 15:06:05 +00:00
|
|
|
|
2011-03-10 10:25:07 +00:00
|
|
|
/* Flags for applet.ctx.stats.flags */
|
2012-12-23 17:15:23 +00:00
|
|
|
#define STAT_FMT_HTML 0x00000001 /* dump the stats in HTML format */
|
[MEDIUM] fix stats socket limitation to 16 kB
Due to the way the stats socket work, it was not possible to
maintain the information related to the command entered, so
after filling a whole buffer, the request was lost and it was
considered that there was nothing to write anymore.
The major reason was that some flags were passed directly
during the first call to stats_dump_raw() instead of being
stored persistently in the session.
To definitely fix this problem, flags were added to the stats
member of the session structure.
A second problem appeared. When the stats were produced, a first
call to client_retnclose() was performed, then one or multiple
subsequent calls to buffer_write_chunks() were done. But once the
stats buffer was full and a reschedule operated, the buffer was
flushed, the write flag cleared from the buffer and nothing was
done to re-arm it.
For this reason, a check was added in the proto_uxst_stats()
function in order to re-call the client FSM when data were added
by stats_dump_raw(). Finally, the whole unix stats dump FSM was
rewritten to avoid all the magics it depended on. It is now
simpler and looks more like the HTTP one.
2008-03-17 20:38:24 +00:00
|
|
|
#define STAT_HIDE_DOWN 0x00000008 /* hide 'down' servers in the stats page */
|
|
|
|
#define STAT_NO_REFRESH 0x00000010 /* do not automatically refresh the stats page */
|
2010-10-11 22:14:36 +00:00
|
|
|
#define STAT_ADMIN 0x00000020 /* indicate a stats admin level */
|
2014-04-22 20:19:53 +00:00
|
|
|
#define STAT_CHUNKED 0x00000040 /* use chunked encoding (HTTP/1.1) */
|
[MEDIUM] fix stats socket limitation to 16 kB
Due to the way the stats socket work, it was not possible to
maintain the information related to the command entered, so
after filling a whole buffer, the request was lost and it was
considered that there was nothing to write anymore.
The major reason was that some flags were passed directly
during the first call to stats_dump_raw() instead of being
stored persistently in the session.
To definitely fix this problem, flags were added to the stats
member of the session structure.
A second problem appeared. When the stats were produced, a first
call to client_retnclose() was performed, then one or multiple
subsequent calls to buffer_write_chunks() were done. But once the
stats buffer was full and a reschedule operated, the buffer was
flushed, the write flag cleared from the buffer and nothing was
done to re-arm it.
For this reason, a check was added in the proto_uxst_stats()
function in order to re-call the client FSM when data were added
by stats_dump_raw(). Finally, the whole unix stats dump FSM was
rewritten to avoid all the magics it depended on. It is now
simpler and looks more like the HTTP one.
2008-03-17 20:38:24 +00:00
|
|
|
#define STAT_BOUND 0x00800000 /* bound statistics to selected proxies/types/services */
|
2007-10-17 16:44:57 +00:00
|
|
|
|
[MAJOR] proto_uxst rework -> SNMP support
Currently there is a ~16KB limit for a data size passed via unix socket.
It is caused by a trivial bug ttat is going to fixed soon, however
in most cases there is no need to dump a full stats.
This patch makes possible to select a scope of dumped data by extending
current "show stat" to "show stat [<iid> <type> <sid>]":
- iid is a proxy id, -1 to dump all proxies
- type selects type of dumpable objects: 1 for frontend, 2 for backend, 4 for
server, -1 for all types. Values can be ORed, for example:
1+2=3 -> frontend+backend.
1+2+4=7 -> frontend+backend+server.
- sid is a service id, -1 to dump everything from the selected proxy.
To do this I implemented a new session flag (SN_STAT_BOUND), added three
variables in data_ctx.stats (iid, type, sid), modified dumpstats.c and
completely revorked the process_uxst_stats: now it waits for a "\n"
terminated string, splits args and uses them. BTW: It should be quite easy
to add new commands, for example to enable/disable servers, the only problem
I can see is a not very lucky config name (*stats* socket). :|
During the work I also fixed two bug:
- s->flags were not initialized for proto_uxst
- missing comma if throttling not enabled (caused by a stupid change in
"Implement persistent id for proxies and servers")
Other changes:
- No more magic type valuse, use STATS_TYPE_FE/STATS_TYPE_BE/STATS_TYPE_SV
- Don't memset full s->data_ctx (it was clearing s->data_ctx.stats.{iid/type/sid},
instead initialize stats.sv & stats.sv_st (stats.px and stats.px_st were already
initialized)
With all that changes it was extremely easy to write a short perl plugin
for a perl-enabled net-snmp (also included in this patch).
29385 is my PEN (Private Enterprise Number) and I'm willing to donate
the SNMPv2-SMI::enterprises.29385.106.* OIDs for HAProxy if there
is nothing assigned already.
2008-03-02 01:42:14 +00:00
|
|
|
#define STATS_TYPE_FE 0
|
|
|
|
#define STATS_TYPE_BE 1
|
|
|
|
#define STATS_TYPE_SV 2
|
2009-10-04 13:43:17 +00:00
|
|
|
#define STATS_TYPE_SO 3
|
[MAJOR] proto_uxst rework -> SNMP support
Currently there is a ~16KB limit for a data size passed via unix socket.
It is caused by a trivial bug ttat is going to fixed soon, however
in most cases there is no need to dump a full stats.
This patch makes possible to select a scope of dumped data by extending
current "show stat" to "show stat [<iid> <type> <sid>]":
- iid is a proxy id, -1 to dump all proxies
- type selects type of dumpable objects: 1 for frontend, 2 for backend, 4 for
server, -1 for all types. Values can be ORed, for example:
1+2=3 -> frontend+backend.
1+2+4=7 -> frontend+backend+server.
- sid is a service id, -1 to dump everything from the selected proxy.
To do this I implemented a new session flag (SN_STAT_BOUND), added three
variables in data_ctx.stats (iid, type, sid), modified dumpstats.c and
completely revorked the process_uxst_stats: now it waits for a "\n"
terminated string, splits args and uses them. BTW: It should be quite easy
to add new commands, for example to enable/disable servers, the only problem
I can see is a not very lucky config name (*stats* socket). :|
During the work I also fixed two bug:
- s->flags were not initialized for proto_uxst
- missing comma if throttling not enabled (caused by a stupid change in
"Implement persistent id for proxies and servers")
Other changes:
- No more magic type valuse, use STATS_TYPE_FE/STATS_TYPE_BE/STATS_TYPE_SV
- Don't memset full s->data_ctx (it was clearing s->data_ctx.stats.{iid/type/sid},
instead initialize stats.sv & stats.sv_st (stats.px and stats.px_st were already
initialized)
With all that changes it was extremely easy to write a short perl plugin
for a perl-enabled net-snmp (also included in this patch).
29385 is my PEN (Private Enterprise Number) and I'm willing to donate
the SNMPv2-SMI::enterprises.29385.106.* OIDs for HAProxy if there
is nothing assigned already.
2008-03-02 01:42:14 +00:00
|
|
|
|
2013-11-22 11:25:24 +00:00
|
|
|
/* HTTP stats : applet.st0 */
|
|
|
|
enum {
|
|
|
|
STAT_HTTP_DONE = 0, /* finished */
|
2013-11-22 16:51:09 +00:00
|
|
|
STAT_HTTP_HEAD, /* send headers before dump */
|
2013-11-22 11:25:24 +00:00
|
|
|
STAT_HTTP_DUMP, /* dumping stats */
|
2013-11-22 16:51:09 +00:00
|
|
|
STAT_HTTP_POST, /* waiting post data */
|
|
|
|
STAT_HTTP_LAST, /* sending last chunk of response */
|
2013-11-22 11:25:24 +00:00
|
|
|
};
|
|
|
|
|
2013-04-15 17:27:10 +00:00
|
|
|
/* HTML form to limit output scope */
|
|
|
|
#define STAT_SCOPE_TXT_MAXLEN 20 /* max len for scope substring */
|
|
|
|
#define STAT_SCOPE_INPUT_NAME "scope" /* pattern form scope name <input> in html form */
|
|
|
|
#define STAT_SCOPE_PATTERN "?" STAT_SCOPE_INPUT_NAME "="
|
|
|
|
|
2015-04-13 11:50:30 +00:00
|
|
|
extern struct applet http_stats_applet;
|
2008-12-07 15:06:43 +00:00
|
|
|
|
2009-09-22 17:31:03 +00:00
|
|
|
void stats_io_handler(struct stream_interface *si);
|
2007-10-17 15:06:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
#endif /* _PROTO_DUMPSTATS_H */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* c-indent-level: 8
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* End:
|
|
|
|
*/
|