]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: stats: Add show json schema
authorSimon Horman <horms@verge.net.au>
Wed, 4 Jan 2017 08:37:26 +0000 (09:37 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 14 Mar 2017 10:14:03 +0000 (11:14 +0100)
commit6f6bb380ef78ad500c38886d30dea5eee2f653aa
tree56c3422d7d6c66387cc153ead315b6e83895f02a
parent05ee213f8b27855d0c6578ced12127e2e1196266
MEDIUM: stats: Add show json schema

This may be used to output the JSON schema which describes the output of
show info json and show stats json.

The JSON output is without any extra whitespace in order to reduce the
volume of output. For human consumption passing the output through a
pretty printer may be helpful.

e.g.:
$ echo "show schema json" | socat /var/run/haproxy.stat stdio | \
     python -m json.tool

The implementation does not generate the schema. Some consideration could
be given to integrating the output of the schema with the output of
typed and json info and stats. In particular the types (u32, s64, etc...)
and tags.

A sample verification of show info json and show stats json using
the schema is as follows. It uses the jsonschema python module:

cat > jschema.py <<  __EOF__
import json

from jsonschema import validate
from jsonschema.validators import Draft3Validator

with open('schema.txt', 'r') as f:
    schema = json.load(f)
    Draft3Validator.check_schema(schema)

    with open('instance.txt', 'r') as f:
        instance = json.load(f)
validate(instance, schema, Draft3Validator)
__EOF__

$ echo "show schema json" | socat /var/run/haproxy.stat stdio > schema.txt
$ echo "show info json" | socat /var/run/haproxy.stat stdio > instance.txt
python ./jschema.py
$ echo "show stats json" | socat /var/run/haproxy.stat stdio > instance.txt
python ./jschema.py

Signed-off-by: Simon Horman <horms@verge.net.au>
doc/management.txt
include/types/stats.h
src/stats.c