mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-09 00:27:08 +02:00
MINOR: stats: create stats fields storage and CSV dump function
The new function stats_dump_fields_csv() currenty walks over all CSV fields and prints all non-empty ones as one line. Strings are csv-encoded on the fly.
This commit is contained in:
parent
f614229b31
commit
82a8602da7
@ -396,6 +396,9 @@ const char *stat_field_names[ST_F_TOTAL_FIELDS] = {
|
|||||||
[ST_F_TTIME] = "ttime",
|
[ST_F_TTIME] = "ttime",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* one line of stats */
|
||||||
|
static struct field stats[ST_F_TOTAL_FIELDS];
|
||||||
|
|
||||||
static int stats_dump_backend_to_buffer(struct stream_interface *si);
|
static int stats_dump_backend_to_buffer(struct stream_interface *si);
|
||||||
static int stats_dump_env_to_buffer(struct stream_interface *si);
|
static int stats_dump_env_to_buffer(struct stream_interface *si);
|
||||||
static int stats_dump_info_to_buffer(struct stream_interface *si);
|
static int stats_dump_info_to_buffer(struct stream_interface *si);
|
||||||
@ -3204,6 +3207,21 @@ static int stats_dump_pools_to_buffer(struct stream_interface *si)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Dump all fields from <stats> into <out> using CSV format */
|
||||||
|
static int stats_dump_fields_csv(struct chunk *out, const struct field *stats)
|
||||||
|
{
|
||||||
|
int field;
|
||||||
|
|
||||||
|
for (field = 0; field < ST_F_TOTAL_FIELDS; field++) {
|
||||||
|
if (!stats_emit_raw_data_field(out, &stats[field]))
|
||||||
|
return 0;
|
||||||
|
if (!chunk_strcat(out, ","))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
chunk_strcat(&trash, "\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Dumps a frontend's line to the trash for the current proxy <px> and uses
|
/* Dumps a frontend's line to the trash for the current proxy <px> and uses
|
||||||
* the state from stream interface <si>. The caller is responsible for clearing
|
* the state from stream interface <si>. The caller is responsible for clearing
|
||||||
* the trash if needed. Returns non-zero if it emits anything, zero otherwise.
|
* the trash if needed. Returns non-zero if it emits anything, zero otherwise.
|
||||||
|
Loading…
Reference in New Issue
Block a user