常田です。

Bluemixを利用していると自分が利用しているリソース状況が知りたいことが結構あると思います。cfコマンドのプラグインを利用して簡単に確認することが出来ますので紹介したいと思います。

cfコマンドのインストール

今回はVagnrant上のUbuntuから実行しています。
* ダウンロードサイト

$ curl -L "https://cli.run.pivotal.io/stable?release=linux64-binary&source=github" | tar -zx
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
100 5393k  100 5393k    0     0   689k      0  0:00:07  0:00:07 --:--:-- 1129k
$ sudo mv cf /usr/local/bin

プラグインの導入

CFコマンドのプラグインを導入します。
プラグインは CloufFoundryのサイト で確認することが出来ます。

まずは利用が出来るようにレポジトリを登録します。

vagrant@vagrant-ubuntu-trusty:~$ cf add-plugin-repo cf-repo http://plugins.cloudfoundry.org/

OK
http://plugins.cloudfoundry.org/list added as 'cf-repo'

プラグインがリストしてみます。

ってやってみると最初から CF-Community として登録されていますね。。

vagrant@vagrant-ubuntu-trusty:~$ cf repo-plugins
Getting plugins from all repositories ...

Repository: CF-Community
name                      version   description
manifest-generator        1.0.0     Help you to generate a manifest from 0 (CLI v6.7.0+)
Firehose Plugin           0.7.0     This plugin allows you to connect to the firehose (CF admins only)
Diego-Enabler             1.0.1     Enable/Disable Diego support for an app (CLI v6.13.0+)
kibana-me-logs            0.4.3     Launches the Kibana UI (from kibana-me-logs) for an application.
Cloud Deployment Plugin   v1.0.1    This plugin allows you to manage application deployment details and manifests in a github repo (like spring cloud config server for deployments)
CLI-Recorder              1.0.2     Records and playbacks CLI commands.
Buildpack Management      1.0.0     Provides a declarative way to configure system buildpacks in a Cloud Foundry installation
Targets                   1.1.0     Easily manage multiple CF targets
blue-green-deploy         1.0.4     Zero downtime deploys with smoke test support
Usage Report              1.1.0     Report on memory usage and application instances for orgs and spaces
Statistics                1.0.0     Display live metrics/statistics about an app
wildcard_plugin           1.0.0     Allows user to search and delete apps using wildcard(*)
Scaleover                 1.0.1     Roll traffic from one app to another by scaling over time
CF App Stack Changer      1.1.0     Allows admins to list and update applications with outdated lucid64 stacks.
cf-download               1.0.0     Plugin for downloading your application contents after staging.
Copy Env                  1.0.0     Expose remote VCAP_SERVICES on the client environment
Buildpack Usage           1.0.0     View all buildpacks used in the current CLI target context.
Test User                 0.0.1     Create a user and assign all possible permissions, organisation and space are created if they do not already exist as well. If no organisation or space name are specified then the default value of 'development' is used
Brooklyn                  0.1.1     Interact with Service Broker for Apache Brooklyn
autopilot                 0.0.1     zero downtime deploy plugin for cf applications
Open                      1.1.0     Open app url in browser
Console                   1.0.0     Start a tmate session on an application container
Live Stats                1.0.0     Monitor CPU and Memory usage on an app via the browser.

Repository: cf-repo
name                      version   description
manifest-generator        1.0.0     Help you to generate a manifest from 0 (CLI v6.7.0+)
Firehose Plugin           0.7.0     This plugin allows you to connect to the firehose (CF admins only)
Diego-Enabler             1.0.1     Enable/Disable Diego support for an app (CLI v6.13.0+)
kibana-me-logs            0.4.3     Launches the Kibana UI (from kibana-me-logs) for an application.
Cloud Deployment Plugin   v1.0.1    This plugin allows you to manage application deployment details and manifests in a github repo (like spring cloud config server for deployments)
CLI-Recorder              1.0.2     Records and playbacks CLI commands.
Buildpack Management      1.0.0     Provides a declarative way to configure system buildpacks in a Cloud Foundry installation
Targets                   1.1.0     Easily manage multiple CF targets
blue-green-deploy         1.0.4     Zero downtime deploys with smoke test support
Usage Report              1.1.0     Report on memory usage and application instances for orgs and spaces
Statistics                1.0.0     Display live metrics/statistics about an app
wildcard_plugin           1.0.0     Allows user to search and delete apps using wildcard(*)
Scaleover                 1.0.1     Roll traffic from one app to another by scaling over time
CF App Stack Changer      1.1.0     Allows admins to list and update applications with outdated lucid64 stacks.
cf-download               1.0.0     Plugin for downloading your application contents after staging.
Copy Env                  1.0.0     Expose remote VCAP_SERVICES on the client environment
Buildpack Usage           1.0.0     View all buildpacks used in the current CLI target context.
Test User                 0.0.1     Create a user and assign all possible permissions, organisation and space are created if they do not already exist as well. If no organisation or space name are specified then the default value of 'development' is used
Brooklyn                  0.1.1     Interact with Service Broker for Apache Brooklyn
autopilot                 0.0.1     zero downtime deploy plugin for cf applications
Open                      1.1.0     Open app url in browser
Console                   1.0.0     Start a tmate session on an application container
Live Stats                1.0.0     Monitor CPU and Memory usage on an app via the browser.

次に今回利用するusage reportを導入してみます。

vagrant@vagrant-ubuntu-trusty:~$ cf install-plugin "Usage Report" -r cf-repo

**Attention: Plugins are binaries written by potentially untrusted authors. Install and use plugins at your own risk.**

Do you want to install the plugin Usage Report? (y or n)> y
Looking up 'Usage Report' from repository 'cf-repo'
7985456 bytes downloaded...
Installing plugin /tmp/usagereport-plugin...
OK
Plugin usage-report v1.1.0 successfully installed.

cfコマンドでログインした状態でプラグインを実行してみます。

vagrant@vagrant-ubuntu-trusty:~$ cf usage-report
Gathering usage information
Org pironak is consuming 0 MB of 524288 MB.
    Space CTS3_151120 is consuming 0 MB memory (0%) of org quota.
        0 apps: 0 running 0 stopped
        0 instances: 0 running, 0 stopped
Org bluemixiphone-contest is consuming 5504 MB of 524288 MB.
    Space dev is consuming 1024 MB memory (0%) of org quota.
        3 apps: 3 running 0 stopped
        3 instances: 3 running, 0 stopped
You are running 3 apps in all orgs, with a total of 3 instances.

このようにすることでORG(組織)単位でのリソース情報が簡単に取得することが出来ました。
その他にも便利なプラグインが有りますので是非ご利用下さい。