From: Sebastien GODARD Date: Fri, 21 Oct 2016 13:46:44 +0000 (+0200) Subject: mpstat, iostat: Use decimal point for FP values in JSON output X-Git-Tag: v11.5.2~13 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a12a567b148f4dca8a695dfa6c51e186dee20e69;p=sysstat mpstat, iostat: Use decimal point for FP values in JSON output This patch sets LC_NUMERIC variable to "C" to make sure JSON output (as displayed by mpstat and iostat commads) is locale-independent and floating-point values use a decimal point. This should make JSON output compliant with RFC7159. Signed-off-by: Sebastien GODARD --- diff --git a/iostat.c b/iostat.c index 1827ec0..21db950 100644 --- a/iostat.c +++ b/iostat.c @@ -1857,6 +1857,11 @@ int main(int argc, char **argv) dm_major = get_devmap_major(); } + if (DISPLAY_JSON_OUTPUT(flags)) { + /* Use a decimal point to make JSON code compliant with RFC7159 */ + setlocale(LC_NUMERIC, "C"); + } + /* Init structures according to machine architecture */ io_sys_init(); if (group_nr > 0) { diff --git a/mpstat.c b/mpstat.c index 8fa3fc1..6c38e00 100644 --- a/mpstat.c +++ b/mpstat.c @@ -1729,6 +1729,11 @@ int main(int argc, char **argv) interval = 0; } + if (DISPLAY_JSON_OUTPUT(flags)) { + /* Use a decimal point to make JSON code compliant with RFC7159 */ + setlocale(LC_NUMERIC, "C"); + } + /* Get time */ get_localtime(&(mp_tstamp[0]), 0);