rackerlabs/developer.rackspace.com — pull request #876 by smashwilson (2014-09-24 17:30:47+00:00)
Title: Make script/lsmon more readable

Running `script/lsmon` gives you a dump of all monitoring resources available on the current account, mostly by using their native string representations. It's complete, but it's also very difficult to read. This removes the `RAX_REGION` environment variable (which is unnecessary because Cloud Monitoring is regionless) and changes the output format to be less complete, but more readable, by grouping Checks and Alarms beneath their associated Entities.

Here's a sample of the new output:

```
-- DFW_entity_staging (id=en7Fovi5Km)

CHECK http_check_sdk : (type=remote.http,id=ch0f4Wun0P)

CHECK http_check_blog : (type=remote.http,id=chDkxCbnW2)

CHECK http_check_index : (type=remote.http,id=chEaJIBIuh)

CHECK http_check_redirect : (type=remote.http,id=chYsEgAQHv)

ALARM DFW_staging_index_is_down : (id=al4clQ3O9j)
check=chEaJIBIuh
notification_plan=npPEeaxqJp
criteria:
:set consecutiveCount=2
if (metric['code'] != "200") {
return new AlarmStatus(CRITICAL, "Non-200 status code #{code} returned.");
} if (metric['body_match'] == "") {
return new AlarmStatus(CRITICAL, "Expected page content not found.");
} if (metric['cert_end_in'] < 5184000) {
return new AlarmStatus(WARNING, "SSL certificate will expire in less than 60 days.");
} return new AlarmStatus(OK);

ALARM DFW_staging_sdk_is_down : (id=albe86uhrV)
check=ch0f4Wun0P
notification_plan=npPEeaxqJp
criteria:
:set consecutiveCount=2
if (metric['code'] != "200") {
return new AlarmStatus(CRITICAL, "Non-200 status code #{code} returned.");
} if (metric['body_match'] == "") {
return new AlarmStatus(CRITICAL, "Expected page content not found.");
} if (metric['cert_end_in'] < 5184000) {
return new AlarmStatus(WARNING, "SSL certificate will expire in less than 60 days.");
} return new AlarmStatus(OK);

ALARM DFW_staging_redirection : (id=alfHO3HAoS)
check=chYsEgAQHv
notification_plan=npPEeaxqJp
criteria:
:set consecutiveCount=2
if (metric['code'] != "301") {
return new AlarmStatus(CRITICAL, "Non-301 status code #{code} returned.");
} return new AlarmStatus(OK);

ALARM DFW_staging_blog_is_down : (id=allxL9nT4S)
check=chDkxCbnW2
notification_plan=npPEeaxqJp
criteria:
:set consecutiveCount=2
if (metric['code'] != "200") {
return new AlarmStatus(CRITICAL, "Non-200 status code #{code} returned.");
} if (metric['body_match'] == "") {
return new AlarmStatus(CRITICAL, "Expected page content not found.");
} if (metric['cert_end_in'] < 5184000) {
return new AlarmStatus(WARNING, "SSL certificate will expire in less than 60 days.");
} return new AlarmStatus(OK);

```

Notifications and Notification Plans are summarized above.