m2x-demo-bluemix-ruby

AT&T M2X Bluemix Demo Application for Ruby

M2X IBM Bluemix Ruby Demo

Introduction

This repo provides a framework for an IBM Bluemix application with Ruby code that reports data to AT&T M2X. The application reports the current system load every minute.

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").

Pre-Requisites

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.

You will also need an account on AT&T's M2X service, which has a free Developer plan and usage based paid plans for higher volumes of data. Check out the M2X Pricing page for more details.

Finally, you will need the Cloudfoundry command line interface installed.

Instructions

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

Environment Variables

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>

Testing

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.

Useful Links

License

This library is released under the MIT license. See LICENSE for the terms.