To simplify parsing command output when integrating with external platforms and web applications, fdpi_ctrl supports JSON output.
To enable JSON output, specify the following additional command-line parameter:
--outformat json
For convenient JSON processing, we recommend installing the jq utility:
yum install epel-release yum-config-manager --disable epel yum --enablerepo epel install jq
Examples:
fdpi_ctrl list all profile --policing --outformat json | jq .
fdpi_ctrl list all --policing --outformat json | jq '.lpolicings[].description.name' | sort | uniq -c
or produce the same statistics in JSON format using jq:
fdpi_ctrl list all --policing --outformat json | jq '[{ name: .lpolicings[].description.name, login: .login }] | group_by(.name) | .[] | { name: .[0].name, count: . | length }'
function fdpi_policing_stat() { fdpi_ctrl list all --policing --outformat json | jq '[{ name: .lpolicings[].description.name, login: .login }] | group_by(.name) | .[] | { name: .[0].name, count: . | length }'; }
and then simply invoked from the command line:
fdpi_policing_stat
To make such functions permanently available, save them in the .bash_profile file.