Output of control commands using the JSON format
Output in JSON format is provided to simplify the parsing of command output when integrating with external platforms and WEB. To do that you should specify an additional option:
--outformat json
For the convenience of working with json, we recommend installing the jq utility:
yum install epel-release yum-config-manager --disable epel yum --enablerepo epel install jq
Examples
Formatted output of the result of the command
fdpi_ctrl list all profile --policing --outformat json|jq .
View usage statistics for different policing profiles
fdpi_ctrl list all --policing --outformat json|jq '.lpolicings[].description.name'|sort|uniq -c
or the same in json format by jq
fdpi_ctrl list all --policing --outformat json|jq '[{ name: .lpolicings[].description.name, login: .login }] | group_by(.name) | .[] | { name: .[0].name, count: . | length}'
For later use, you can turn this into a bash function
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 just call this function from the command line
fdpi_policing_stat
For regular use of functions you can save them in a .bash_profile file.