2006-06-25 20:48:02 -04:00
|
|
|
/*
|
2009-12-21 14:11:07 -05:00
|
|
|
* include/types/session.h
|
|
|
|
|
* This file defines everything related to sessions.
|
|
|
|
|
*
|
2010-01-22 13:10:05 -05:00
|
|
|
* Copyright (C) 2000-2010 Willy Tarreau - w@1wt.eu
|
2009-12-21 14:11:07 -05: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
|
|
|
|
|
*/
|
2006-06-25 20:48:02 -04:00
|
|
|
|
|
|
|
|
#ifndef _TYPES_SESSION_H
|
|
|
|
|
#define _TYPES_SESSION_H
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
|
2006-06-29 12:54:54 -04:00
|
|
|
#include <common/config.h>
|
2006-06-29 11:53:05 -04:00
|
|
|
#include <common/mini-clist.h>
|
2006-06-25 20:48:02 -04:00
|
|
|
|
|
|
|
|
#include <types/buffers.h>
|
2007-03-18 12:31:28 -04:00
|
|
|
#include <types/proto_http.h>
|
2006-06-25 20:48:02 -04:00
|
|
|
#include <types/proxy.h>
|
|
|
|
|
#include <types/queue.h>
|
|
|
|
|
#include <types/server.h>
|
[MAJOR] rework of the server FSM
srv_state has been removed from HTTP state machines, and states
have been split in either TCP states or analyzers. For instance,
the TARPIT state has just become a simple analyzer.
New flags have been added to the struct buffer to compensate this.
The high-level stream processors sometimes need to force a disconnection
without touching a file-descriptor (eg: report an error). But if
they touched BF_SHUTW or BF_SHUTR, the file descriptor would not
be closed. Thus, the two SHUT?_NOW flags have been added so that
an application can request a forced close which the stream interface
will be forced to obey.
During this change, a new BF_HIJACK flag was added. It will
be used for data generation, eg during a stats dump. It
prevents the producer on a buffer from sending data into it.
BF_SHUTR_NOW /* the producer must shut down for reads ASAP */
BF_SHUTW_NOW /* the consumer must shut down for writes ASAP */
BF_HIJACK /* the producer is temporarily replaced */
BF_SHUTW_NOW has precedence over BF_HIJACK. BF_HIJACK has
precedence over BF_MAY_FORWARD (so that it does not need it).
New functions buffer_shutr_now(), buffer_shutw_now(), buffer_abort()
are provided to manipulate BF_SHUT* flags.
A new type "stream_interface" has been added to describe both
sides of a buffer. A stream interface has states and error
reporting. The session now has two stream interfaces (one per
side). Each buffer has stream_interface pointers to both
consumer and producer sides.
The server-side file descriptor has moved to its stream interface,
so that even the buffer has access to it.
process_srv() has been split into three parts :
- tcp_get_connection() obtains a connection to the server
- tcp_connection_failed() tests if a previously attempted
connection has succeeded or not.
- process_srv_data() only manages the data phase, and in
this sense should be roughly equivalent to process_cli.
Little code has been removed, and a lot of old code has been
left in comments for now.
2008-10-19 01:30:41 -04:00
|
|
|
#include <types/stream_interface.h>
|
2006-06-25 20:48:02 -04:00
|
|
|
#include <types/task.h>
|
2010-01-04 09:45:53 -05:00
|
|
|
#include <types/stick_table.h>
|
2006-06-25 20:48:02 -04:00
|
|
|
|
|
|
|
|
|
2008-01-06 10:36:16 -05:00
|
|
|
/* various session flags, bits values 0x01 to 0x100 (shift 0) */
|
2006-06-25 20:48:02 -04:00
|
|
|
#define SN_DIRECT 0x00000001 /* connection made on the server matching the client cookie */
|
2007-03-18 13:34:41 -04:00
|
|
|
#define SN_ASSIGNED 0x00000002 /* no need to assign a server to this session */
|
|
|
|
|
#define SN_ADDR_SET 0x00000004 /* this session's server address has been set */
|
|
|
|
|
#define SN_BE_ASSIGNED 0x00000008 /* a backend was assigned. Conns are accounted. */
|
2009-12-21 14:11:07 -05:00
|
|
|
|
2010-01-22 13:10:05 -05:00
|
|
|
#define SN_FORCE_PRST 0x00000010 /* force persistence here, even if server is down */
|
2007-03-18 13:34:41 -04:00
|
|
|
#define SN_MONITOR 0x00000020 /* this session comes from a monitoring system */
|
2008-11-11 14:20:02 -05:00
|
|
|
#define SN_CURR_SESS 0x00000040 /* a connection is currently being counted on the server */
|
2007-05-08 13:46:30 -04:00
|
|
|
#define SN_FRT_ADDR_SET 0x00000080 /* set if the frontend address has been filled */
|
2008-01-06 10:36:16 -05:00
|
|
|
#define SN_REDISP 0x00000100 /* set if this session was redispatched from one server to another */
|
2008-01-06 17:34:21 -05:00
|
|
|
#define SN_CONN_TAR 0x00000200 /* set if this session is turning around before reconnecting */
|
2008-02-14 14:25:24 -05:00
|
|
|
#define SN_REDIRECTABLE 0x00000400 /* set if this session is redirectable (GET or HEAD) */
|
2009-11-30 06:19:56 -05:00
|
|
|
#define SN_TUNNEL 0x00000800 /* tunnel-mode session, nothing to catch after data */
|
2006-06-25 20:48:02 -04:00
|
|
|
|
2008-01-06 10:36:16 -05:00
|
|
|
/* session termination conditions, bits values 0x1000 to 0x7000 (0-7 shift 12) */
|
|
|
|
|
#define SN_ERR_NONE 0x00000000
|
|
|
|
|
#define SN_ERR_CLITO 0x00001000 /* client time-out */
|
|
|
|
|
#define SN_ERR_CLICL 0x00002000 /* client closed (read/write error) */
|
|
|
|
|
#define SN_ERR_SRVTO 0x00003000 /* server time-out, connect time-out */
|
|
|
|
|
#define SN_ERR_SRVCL 0x00004000 /* server closed (connect/read/write error) */
|
|
|
|
|
#define SN_ERR_PRXCOND 0x00005000 /* the proxy decided to close (deny...) */
|
|
|
|
|
#define SN_ERR_RESOURCE 0x00006000 /* the proxy encountered a lack of a local resources (fd, mem, ...) */
|
|
|
|
|
#define SN_ERR_INTERNAL 0x00007000 /* the proxy encountered an internal error */
|
|
|
|
|
#define SN_ERR_MASK 0x00007000 /* mask to get only session error flags */
|
|
|
|
|
#define SN_ERR_SHIFT 12 /* bit shift */
|
2007-03-18 13:34:41 -04:00
|
|
|
/* unused: 0x00008000 */
|
2006-06-25 20:48:02 -04:00
|
|
|
|
2008-01-06 10:36:16 -05:00
|
|
|
/* session state at termination, bits values 0x10000 to 0x70000 (0-7 shift 16) */
|
|
|
|
|
#define SN_FINST_R 0x00010000 /* session ended during client request */
|
|
|
|
|
#define SN_FINST_C 0x00020000 /* session ended during server connect */
|
|
|
|
|
#define SN_FINST_H 0x00030000 /* session ended during server headers */
|
|
|
|
|
#define SN_FINST_D 0x00040000 /* session ended during data phase */
|
|
|
|
|
#define SN_FINST_L 0x00050000 /* session ended while pushing last data to client */
|
|
|
|
|
#define SN_FINST_Q 0x00060000 /* session ended while waiting in queue for a server slot */
|
|
|
|
|
#define SN_FINST_T 0x00070000 /* session ended tarpitted */
|
|
|
|
|
#define SN_FINST_MASK 0x00070000 /* mask to get only final session state flags */
|
|
|
|
|
#define SN_FINST_SHIFT 16 /* bit shift */
|
|
|
|
|
/* unused: 0x00080000 */
|
|
|
|
|
|
2007-01-07 09:46:13 -05:00
|
|
|
/* WARNING: if new fields are added, they must be initialized in event_accept()
|
|
|
|
|
* and freed in session_free() !
|
|
|
|
|
*/
|
[BUG] fix the dequeuing logic to ensure that all requests get served
The dequeuing logic was completely wrong. First, a task was assigned
to all servers to process the queue, but this task was never scheduled
and was only woken up on session free. Second, there was no reservation
of server entries when a task was assigned a server. This means that
as long as the task was not connected to the server, its presence was
not accounted for. This was causing trouble when detecting whether or
not a server had reached maxconn. Third, during a redispatch, a session
could lose its place at the server's and get blocked because another
session at the same moment would have stolen the entry. Fourth, the
redispatch option did not work when maxqueue was reached for a server,
and it was not possible to do so without indefinitely hanging a session.
The root cause of all those problems was the lack of pre-reservation of
connections at the server's, and the lack of tracking of servers during
a redispatch. Everything relied on combinations of flags which could
appear similarly in quite distinct situations.
This patch is a major rework but there was no other solution, as the
internal logic was deeply flawed. The resulting code is cleaner, more
understandable, uses less magics and is overall more robust.
As an added bonus, "option redispatch" now works when maxqueue has
been reached on a server.
2008-06-20 09:04:11 -04:00
|
|
|
|
2008-08-16 08:55:08 -04:00
|
|
|
/* Termination sequence tracing.
|
|
|
|
|
*
|
|
|
|
|
* These values have to be set into the field term_trace of a session when
|
|
|
|
|
* closing a session (half or full). They are only meant for post-mortem
|
|
|
|
|
* analysis. The value must be assigned this way :
|
|
|
|
|
* trace_term(s, TT_XXX);
|
|
|
|
|
*
|
|
|
|
|
* One TT_XXX value is assigned to each location in the code which may be
|
|
|
|
|
* involved in a connection closing. Since a full session close generally
|
|
|
|
|
* involves 4 steps, we will be able to read these steps afterwards by simply
|
|
|
|
|
* checking the code. Value TT_NONE is zero and must never be set, as it means
|
|
|
|
|
* the connection was not closed. Value TT_ANON must be used when no value was
|
|
|
|
|
* assigned to a specific code part. Never ever reuse an already assigned code
|
|
|
|
|
* as it will defeat the purpose of this trace. It is wise to use a per-file
|
|
|
|
|
* anonymous value though.
|
|
|
|
|
*/
|
|
|
|
|
#define TT_BIT_SHIFT 8
|
|
|
|
|
enum {
|
|
|
|
|
TT_NONE = 0,
|
|
|
|
|
TT_ANON = 1,
|
|
|
|
|
TT_CLIENT = 0x10,
|
|
|
|
|
TT_CLIENT_1,
|
|
|
|
|
TT_CLIENT_2,
|
|
|
|
|
TT_HTTP_CLI = 0x20,
|
|
|
|
|
TT_HTTP_CLI_1,
|
|
|
|
|
TT_HTTP_CLI_2,
|
|
|
|
|
TT_HTTP_CLI_3,
|
|
|
|
|
TT_HTTP_CLI_4,
|
|
|
|
|
TT_HTTP_CLI_5,
|
|
|
|
|
TT_HTTP_CLI_6,
|
|
|
|
|
TT_HTTP_CLI_7,
|
|
|
|
|
TT_HTTP_CLI_8,
|
|
|
|
|
TT_HTTP_CLI_9,
|
|
|
|
|
TT_HTTP_CLI_10,
|
|
|
|
|
TT_HTTP_SRV = 0x30,
|
|
|
|
|
TT_HTTP_SRV_1,
|
|
|
|
|
TT_HTTP_SRV_2,
|
|
|
|
|
TT_HTTP_SRV_3,
|
|
|
|
|
TT_HTTP_SRV_4,
|
|
|
|
|
TT_HTTP_SRV_5,
|
|
|
|
|
TT_HTTP_SRV_6,
|
|
|
|
|
TT_HTTP_SRV_7,
|
|
|
|
|
TT_HTTP_SRV_8,
|
|
|
|
|
TT_HTTP_SRV_9,
|
|
|
|
|
TT_HTTP_SRV_10,
|
|
|
|
|
TT_HTTP_SRV_11,
|
|
|
|
|
TT_HTTP_SRV_12,
|
|
|
|
|
TT_HTTP_SRV_13,
|
|
|
|
|
TT_HTTP_SRV_14,
|
|
|
|
|
TT_HTTP_CNT = 0x40,
|
|
|
|
|
TT_HTTP_CNT_1,
|
|
|
|
|
TT_HTTP_URI = 0x50,
|
|
|
|
|
TT_HTTP_URI_1,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
[BUG] fix the dequeuing logic to ensure that all requests get served
The dequeuing logic was completely wrong. First, a task was assigned
to all servers to process the queue, but this task was never scheduled
and was only woken up on session free. Second, there was no reservation
of server entries when a task was assigned a server. This means that
as long as the task was not connected to the server, its presence was
not accounted for. This was causing trouble when detecting whether or
not a server had reached maxconn. Third, during a redispatch, a session
could lose its place at the server's and get blocked because another
session at the same moment would have stolen the entry. Fourth, the
redispatch option did not work when maxqueue was reached for a server,
and it was not possible to do so without indefinitely hanging a session.
The root cause of all those problems was the lack of pre-reservation of
connections at the server's, and the lack of tracking of servers during
a redispatch. Everything relied on combinations of flags which could
appear similarly in quite distinct situations.
This patch is a major rework but there was no other solution, as the
internal logic was deeply flawed. The resulting code is cleaner, more
understandable, uses less magics and is overall more robust.
As an added bonus, "option redispatch" now works when maxqueue has
been reached on a server.
2008-06-20 09:04:11 -04:00
|
|
|
/*
|
|
|
|
|
* Note: some session flags have dependencies :
|
|
|
|
|
* - SN_DIRECT cannot exist without SN_ASSIGNED, because a server is
|
|
|
|
|
* immediately assigned when SN_DIRECT is determined. Both must be cleared
|
|
|
|
|
* when clearing SN_DIRECT (eg: redispatch).
|
|
|
|
|
* - ->srv has no meaning without SN_ASSIGNED and must not be checked without
|
|
|
|
|
* it. ->prev_srv should be used to check previous ->srv. If SN_ASSIGNED is
|
|
|
|
|
* set and sess->srv is NULL, then it is a dispatch or proxy mode.
|
|
|
|
|
* - a session being processed has srv_conn set.
|
|
|
|
|
* - srv_conn might remain after SN_DIRECT has been reset, but the assigned
|
|
|
|
|
* server should eventually be released.
|
|
|
|
|
*/
|
2006-06-25 20:48:02 -04:00
|
|
|
struct session {
|
2008-11-23 13:53:55 -05:00
|
|
|
struct list list; /* position in global sessions list */
|
2008-12-07 14:16:23 -05:00
|
|
|
struct list back_refs; /* list of users tracking this session */
|
2006-06-25 20:48:02 -04:00
|
|
|
struct task *task; /* the task associated with this session */
|
|
|
|
|
/* application specific below */
|
2008-12-07 10:45:10 -05:00
|
|
|
struct listener *listener; /* the listener by which the request arrived */
|
2006-11-30 05:40:23 -05:00
|
|
|
struct proxy *fe; /* the proxy this session depends on for the client side */
|
|
|
|
|
struct proxy *be; /* the proxy this session depends on for the server side */
|
2006-06-25 20:48:02 -04:00
|
|
|
int conn_retries; /* number of connect retries left */
|
|
|
|
|
int flags; /* some flags describing the session */
|
2008-08-16 08:55:08 -04:00
|
|
|
unsigned term_trace; /* term trace: 4*8 bits indicating which part of the code closed */
|
2006-06-25 20:48:02 -04:00
|
|
|
struct buffer *req; /* request buffer */
|
|
|
|
|
struct buffer *rep; /* response buffer */
|
[MAJOR] rework of the server FSM
srv_state has been removed from HTTP state machines, and states
have been split in either TCP states or analyzers. For instance,
the TARPIT state has just become a simple analyzer.
New flags have been added to the struct buffer to compensate this.
The high-level stream processors sometimes need to force a disconnection
without touching a file-descriptor (eg: report an error). But if
they touched BF_SHUTW or BF_SHUTR, the file descriptor would not
be closed. Thus, the two SHUT?_NOW flags have been added so that
an application can request a forced close which the stream interface
will be forced to obey.
During this change, a new BF_HIJACK flag was added. It will
be used for data generation, eg during a stats dump. It
prevents the producer on a buffer from sending data into it.
BF_SHUTR_NOW /* the producer must shut down for reads ASAP */
BF_SHUTW_NOW /* the consumer must shut down for writes ASAP */
BF_HIJACK /* the producer is temporarily replaced */
BF_SHUTW_NOW has precedence over BF_HIJACK. BF_HIJACK has
precedence over BF_MAY_FORWARD (so that it does not need it).
New functions buffer_shutr_now(), buffer_shutw_now(), buffer_abort()
are provided to manipulate BF_SHUT* flags.
A new type "stream_interface" has been added to describe both
sides of a buffer. A stream interface has states and error
reporting. The session now has two stream interfaces (one per
side). Each buffer has stream_interface pointers to both
consumer and producer sides.
The server-side file descriptor has moved to its stream interface,
so that even the buffer has access to it.
process_srv() has been split into three parts :
- tcp_get_connection() obtains a connection to the server
- tcp_connection_failed() tests if a previously attempted
connection has succeeded or not.
- process_srv_data() only manages the data phase, and in
this sense should be roughly equivalent to process_cli.
Little code has been removed, and a lot of old code has been
left in comments for now.
2008-10-19 01:30:41 -04:00
|
|
|
struct stream_interface si[2]; /* client and server stream interfaces */
|
2006-06-25 20:48:02 -04:00
|
|
|
struct sockaddr_storage cli_addr; /* the client address */
|
2007-05-08 13:46:30 -04:00
|
|
|
struct sockaddr_storage frt_addr; /* the frontend address reached by the client if SN_FRT_ADDR_SET is set */
|
2006-06-25 20:48:02 -04:00
|
|
|
struct sockaddr_in srv_addr; /* the address to connect to */
|
[BUG] fix the dequeuing logic to ensure that all requests get served
The dequeuing logic was completely wrong. First, a task was assigned
to all servers to process the queue, but this task was never scheduled
and was only woken up on session free. Second, there was no reservation
of server entries when a task was assigned a server. This means that
as long as the task was not connected to the server, its presence was
not accounted for. This was causing trouble when detecting whether or
not a server had reached maxconn. Third, during a redispatch, a session
could lose its place at the server's and get blocked because another
session at the same moment would have stolen the entry. Fourth, the
redispatch option did not work when maxqueue was reached for a server,
and it was not possible to do so without indefinitely hanging a session.
The root cause of all those problems was the lack of pre-reservation of
connections at the server's, and the lack of tracking of servers during
a redispatch. Everything relied on combinations of flags which could
appear similarly in quite distinct situations.
This patch is a major rework but there was no other solution, as the
internal logic was deeply flawed. The resulting code is cleaner, more
understandable, uses less magics and is overall more robust.
As an added bonus, "option redispatch" now works when maxqueue has
been reached on a server.
2008-06-20 09:04:11 -04:00
|
|
|
struct server *srv; /* the server the session will be running or has been running on */
|
|
|
|
|
struct server *srv_conn; /* session already has a slot on a server and is not in queue */
|
|
|
|
|
struct server *prev_srv; /* the server the was running on, after a redispatch, otherwise NULL */
|
2006-06-25 20:48:02 -04:00
|
|
|
struct pendconn *pend_pos; /* if not NULL, points to the position in the pending queue */
|
2007-03-03 07:54:32 -05:00
|
|
|
struct http_txn txn; /* current HTTP transaction being processed. Should become a list. */
|
2010-01-04 09:45:53 -05:00
|
|
|
|
|
|
|
|
struct {
|
|
|
|
|
struct stksess *ts;
|
|
|
|
|
struct stktable *table;
|
|
|
|
|
int flags;
|
|
|
|
|
} store[8]; /* tracked stickiness values to store */
|
|
|
|
|
int store_count;
|
|
|
|
|
|
2006-06-25 20:48:02 -04:00
|
|
|
struct {
|
|
|
|
|
int logwait; /* log fields waiting to be collected : LW_* */
|
2008-06-22 11:18:02 -04:00
|
|
|
struct timeval accept_date; /* date of the accept() in user date */
|
|
|
|
|
struct timeval tv_accept; /* date of the accept() in internal date (monotonic) */
|
2008-06-13 15:12:51 -04:00
|
|
|
struct timeval tv_request; /* date the request arrives, {0,0} if never occurs */
|
2006-06-25 20:48:02 -04:00
|
|
|
long t_queue; /* delay before the session gets out of the connect queue, -1 if never occurs */
|
|
|
|
|
long t_connect; /* delay before the connect() to the server succeeds, -1 if never occurs */
|
|
|
|
|
long t_data; /* delay before the first data byte from the server ... */
|
2007-03-18 12:31:28 -04:00
|
|
|
unsigned long t_close; /* total session duration */
|
2006-06-25 20:48:02 -04:00
|
|
|
unsigned long srv_queue_size; /* number of sessions waiting for a connect slot on this server at accept() time (in direct assignment) */
|
|
|
|
|
unsigned long prx_queue_size; /* overall number of sessions waiting for a connect slot on this instance at accept() time */
|
2007-01-01 18:28:21 -05:00
|
|
|
long long bytes_in; /* number of bytes transferred from the client to the server */
|
|
|
|
|
long long bytes_out; /* number of bytes transferred from the server to the client */
|
2006-06-25 20:48:02 -04:00
|
|
|
} logs;
|
2008-11-30 14:44:17 -05:00
|
|
|
void (*do_log)(struct session *s); /* the function to call in order to log (or NULL) */
|
|
|
|
|
void (*srv_error)(struct session *s, /* the function to call upon unrecoverable server errors (or NULL) */
|
|
|
|
|
struct stream_interface *si);
|
2006-06-25 20:48:02 -04:00
|
|
|
short int data_source; /* where to get the data we generate ourselves */
|
|
|
|
|
short int data_state; /* where to get the data we generate ourselves */
|
|
|
|
|
union {
|
|
|
|
|
struct {
|
|
|
|
|
struct proxy *px;
|
|
|
|
|
struct server *sv;
|
2009-10-04 09:43:17 -04:00
|
|
|
struct listener *l;
|
2006-06-25 20:48:02 -04:00
|
|
|
short px_st, sv_st; /* DATA_ST_INIT or DATA_ST_DATA */
|
[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 16:38:24 -04:00
|
|
|
unsigned int flags; /* STAT_* */
|
[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-01 20:42:14 -05:00
|
|
|
int iid, type, sid; /* proxy id, type and service id if bounding of stats is enabled */
|
2006-06-25 20:48:02 -04:00
|
|
|
} stats;
|
2008-12-07 16:29:48 -05:00
|
|
|
struct {
|
|
|
|
|
struct bref bref;
|
|
|
|
|
} sess;
|
2009-03-04 09:53:18 -05:00
|
|
|
struct {
|
|
|
|
|
int iid; /* if >= 0, ID of the proxy to filter on */
|
|
|
|
|
struct proxy *px; /* current proxy being dumped, NULL = not started yet. */
|
|
|
|
|
unsigned int buf; /* buffer being dumped, 0 = req, 1 = rep */
|
|
|
|
|
unsigned int sid; /* session ID of error being dumped */
|
|
|
|
|
int ptr; /* <0: headers, >=0 : text pointer to restart from */
|
|
|
|
|
int bol; /* pointer to beginning of current line */
|
|
|
|
|
} errors;
|
2009-10-11 17:12:51 -04:00
|
|
|
struct {
|
|
|
|
|
const char *msg; /* pointer to a persistent message to be returned in PRINT state */
|
|
|
|
|
} cli;
|
2009-10-04 09:56:38 -04:00
|
|
|
} data_ctx; /* used by stats I/O handlers to dump the stats */
|
2006-06-25 20:48:02 -04:00
|
|
|
unsigned int uniq_id; /* unique ID used for the traces */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* _TYPES_SESSION_H */
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Local variables:
|
|
|
|
|
* c-indent-level: 8
|
|
|
|
|
* c-basic-offset: 8
|
|
|
|
|
* End:
|
|
|
|
|
*/
|