M2X IBM Bluemix Ruby Demo
Please note that AT&T's M2X reports times in UTC, not in your local time zone. M2X will, however, accept data in any time zone as long as the timestamp is formatted using ISO8601 (e.g. "2015-02-27T18:14:00.000-03:00").
You will need to have an IBM ID (sign-up here). The account you make will be a free trial account that is good for 30 days. If you confirm your account using a credit card, this application will still be free to run because it only needs one instance and less than 512MB of memory.
Finally, you will need the Cloudfoundry command line interface installed.
Creating Your Application
$ git clone https://github.com/attm2x/m2x-demo-bluemix-ruby.git $ cd m2x-demo-bluemix-ruby
Connect, login and deploy to Bluemix
Make sure you have installed the Cloudfoundry command line interface for your system.
First connect to Bluemix.
$ cf api https://api.ng.bluemix.net
Then login using your IBM ID.
$ cf login -u <email used as IBM ID> $ cf target -o <email used as IBM ID> -s dev
Deploy the app, but don't start it yet (you will need your M2X API Master Key first).
$ cf push <app name> -m 512m -c "ruby master.rb" --no-route --no-start
Device Name (Optional)
The default device name is "loadreport-bluemix". If you plan to have this application running as a distribution of devices you should probably use different names for each device.
If you'd like your to use a different name this can be done by setting the device name as an environment variable on Bluemix:
$ cf set-env <app name> DEVICE_NAME <Custom Device Name>
M2X API Key
To get your M2X API Master Key, login to M2X, and click your name in the upper right-hand corner, then the "Account Settings" dropdown, then the "Master Keys" tab. Here's a direct link.
Then you'll need to add your key as an environment variable on your Bluemix instance:
$ cf set-env <app name> MASTER_API_KEY <M2X API Master Key>
Finally, start your application.
cf start <app name>
Your application should now be reporting the system load to AT&T M2X every minute.
If there are any errors, they will be logged via Bluemix's log system. Use
cf logs <app name> --recent to see the live output from your application.
- Start coding with Cloud Foundry command line interface
- CF commands
- IBM Bluemix Documentation
- M2X API Documentation
This library is released under the MIT license. See
LICENSE for the terms.