]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stats: support an optional "float" option to "show info"
authorWilly Tarreau <w@1wt.eu>
Sat, 8 May 2021 05:54:24 +0000 (07:54 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 8 May 2021 08:52:12 +0000 (10:52 +0200)
This will allow some fields to be produced with a higher accuracy when
the requester indicates being able to parse floats. Rates and times are
among the elements which can make sense.

doc/management.txt
include/haproxy/stats-t.h
src/stats.c

index 0a69cbd28c76e82e1b1c0a6fc51f1d282d750dd2..75e872bc6551e465b8f197b3d83d9e5839052580 100644 (file)
@@ -2295,7 +2295,7 @@ show fd [<fd>]
   suffixed with an exclamation mark ('!'). This may help find a starting point
   when trying to diagnose an incident.
 
-show info [typed|json] [desc]
+show info [typed|json] [desc] [float]
   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
@@ -2306,7 +2306,11 @@ show info [typed|json] [desc]
   delimited by a colon (':'). The left one is the field name and the right
   one is the value.  It is very important to note that in typed output
   format, the dump for a single object is contiguous so that there is no
-  need for a consumer to store everything at once.
+  need for a consumer to store everything at once. If "float" is passed as an
+  optional argument, some fields usually emitted as integers may switch to
+  floats for higher accuracy. It is purposely unspecified which ones are
+  concerned as this might evolve over time. Using this option implies that the
+  consumer is able to process floats. The output format used is sprintf("%f").
 
   When using the typed output format, each line is made of 4 columns delimited
   by colons (':'). The first column is a dot-delimited series of 3 elements. The
index 4ab1138eaa1b7121717ce4c7d86d195e9175e2e1..e87743237f1474221b4836c01b71de41e4f5d91d 100644 (file)
@@ -42,6 +42,7 @@
 #define STAT_SHMODULES  0x00002000      /* conf: show modules */
 #define STAT_HIDE_MAINT 0x00004000     /* hide maint/disabled servers */
 #define STAT_CONVDONE   0x00008000     /* conf: rules conversion done */
+#define STAT_USE_FLOAT  0x00010000      /* use floats where possible in the outputs */
 
 #define STAT_BOUND      0x00800000     /* bound statistics to selected proxies/types/services */
 #define STAT_STARTED    0x01000000     /* some output has occurred */
index b2bda29b4690b8564a76c4970e0f4f3767e11ebb..a352a9bc22bda2b744e4c217256ad6cadd2764a8 100644 (file)
@@ -4788,6 +4788,8 @@ static int cli_parse_show_info(char **args, char *payload, struct appctx *appctx
                        appctx->ctx.stats.flags = (appctx->ctx.stats.flags & ~STAT_FMT_MASK) | STAT_FMT_JSON;
                else if (strcmp(args[arg], "desc") == 0)
                        appctx->ctx.stats.flags |= STAT_SHOW_FDESC;
+               else if (strcmp(args[arg], "float") == 0)
+                       appctx->ctx.stats.flags |= STAT_USE_FLOAT;
                arg++;
        }
        return 0;
@@ -5111,7 +5113,7 @@ REGISTER_PER_THREAD_FREE(free_trash_counters);
 /* register cli keywords */
 static struct cli_kw_list cli_kws = {{ },{
        { { "clear", "counters",  NULL },      "clear counters [all]                    : clear max statistics counters (or all counters)", cli_parse_clear_counters, NULL, NULL },
-       { { "show", "info",  NULL },           "show info [desc|json|typed]*            : report information about the running process",    cli_parse_show_info, cli_io_handler_dump_info, NULL },
+       { { "show", "info",  NULL },           "show info [desc|json|typed|float]*      : report information about the running process",    cli_parse_show_info, cli_io_handler_dump_info, NULL },
        { { "show", "stat",  NULL },           "show stat [desc|json|no-maint|typed|up]*: report counters for each proxy and server",       cli_parse_show_stat, cli_io_handler_dump_stat, NULL },
        { { "show", "schema",  "json", NULL }, "show schema json                        : report schema used for stats",                    NULL, cli_io_handler_dump_json_schema, NULL },
        {{},}