MINOR: stats: make "show stat" and "show info"

Now "show info" supports "desc" after the default and "typed" formats,
and "show stat" supports this after the typed format. In both cases
this appends the description for the represented metric between double
quotes. The same could be done for JSON output but would possibly require
to update the schema first.
This commit is contained in:
Willy Tarreau 2019-10-09 15:44:21 +02:00
parent eaa55370c3
commit 6b19b142e8
2 changed files with 16 additions and 2 deletions

View File

@ -1994,7 +1994,7 @@ show fd [<fd>]
that the output format may evolve over time so this output must not be parsed
by tools designed to be durable.
show info [typed|json]
show info [typed|json] [desc]
Dump info about haproxy status on current process. If "typed" is passed as an
optional argument, field numbers, names and types are emitted as well so that
external monitoring products can easily retrieve, possibly aggregate, then
@ -2026,6 +2026,10 @@ show info [typed|json]
<field_pos>.<field_name>.<process_num>:<tags>:<type>:<value>
When "desc" is appended to the command, one extra colon followed by a quoted
string is appended with a description for the metric. At the time of writing,
this is only supported for the "typed" and default output formats.
Example :
> show info
@ -2285,7 +2289,7 @@ show sess <id>
The special id "all" dumps the states of all sessions, which must be avoided
as much as possible as it is highly CPU intensive and can take a lot of time.
show stat [{<iid>|<proxy>} <type> <sid>] [typed|json]
show stat [{<iid>|<proxy>} <type> <sid>] [typed|json] [desc]
Dump statistics using the CSV format; using the extended typed output
format described in the section above if "typed" is passed after the
other arguments; or in JSON if "json" is passed after the other arguments
@ -2359,6 +2363,10 @@ show stat [{<iid>|<proxy>} <type> <sid>] [typed|json]
"str". Then the fourth column is the value itself, which the consumer knows
how to parse thanks to column 3 and how to process thanks to column 2.
When "desc" is appended to the command, one extra colon followed by a quoted
string is appended with a description for the metric. At the time of writing,
this is only supported for the "typed" output format.
Thus the overall line format in typed mode is :
<obj>.<px_id>.<id>.<fpos>.<fname>.<process_num>:<tags>:<type>:<value>

View File

@ -544,6 +544,8 @@ static int stats_dump_fields_typed(struct buffer *out,
return 0;
if (!stats_emit_typed_data_field(out, &stats[field]))
return 0;
if ((flags & STAT_SHOW_FDESC) && !chunk_appendf(out, ":\"%s\"", stat_fields[field].desc))
return 0;
if (!chunk_strcat(out, "\n"))
return 0;
}
@ -3327,6 +3329,8 @@ static int stats_dump_info_fields(struct buffer *out,
return 0;
if (!stats_emit_raw_data_field(out, &info[field]))
return 0;
if ((flags & STAT_SHOW_FDESC) && !chunk_appendf(out, ":\"%s\"", info_fields[field].desc))
return 0;
if (!chunk_strcat(out, "\n"))
return 0;
}
@ -3349,6 +3353,8 @@ static int stats_dump_typed_info_fields(struct buffer *out,
return 0;
if (!stats_emit_typed_data_field(out, &info[field]))
return 0;
if ((flags & STAT_SHOW_FDESC) && !chunk_appendf(out, ":\"%s\"", info_fields[field].desc))
return 0;
if (!chunk_strcat(out, "\n"))
return 0;
}