last year we evaluated several options and the one deemed realistic was using a "reporting" tool at the time under development (the other options were complicated or unstable).
Not sure it's now available but worth checking.
We were looking at this one from the Cloud Foundry plugin site called Usage report.. Is this the one you were referring to?
It will probably need some adaptation but the source code is there
install-plugin - Install Cloud Foundry with CLI plugin
cf install-plugin PLUGIN_NAME [-r REPO_NAME] [-f]
cf install-plugin LOCAL-PATH/TO/PLUGIN | URL [-f]
Plugins are binaries written by potentially untrusted authors. Install and use plugins at your own risk.
cf install-plugin ~/Downloads/plugin-foobar
cf install-plugin https://example.com/plugin-foobar_linux_amd64
cf install-plugin -r My-Repo plugin-echo
Force install of plugin without confirmation
Restrict search for plugin to this registered repository
add-plugin-repo, list-plugin-repos, plugins