]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stats: make "show stat" and "show info"
authorWilly Tarreau <w@1wt.eu>
Wed, 9 Oct 2019 13:44:21 +0000 (15:44 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 10 Oct 2019 09:30:07 +0000 (11:30 +0200)
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.

doc/management.txt
src/stats.c

index 73fda8974858e6f40bb3ef0f63f7aa2514257dde..d56a031a07a554f0dfaa66386ca96087564f4963 100644 (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>
index e9cbb96847c95bf088663b0108be7feae8d15b8b..69fe9a8ebabe41d6d950e3d923c78bd3a8528c36 100644 (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;
        }