Update to check median instead of last value.

The check by graphite-data.rb was only checking the latest value
returned by the graphite target, which in certain corner cases was
giving false positives for:

```
asPercent(metrics.:::metric_prefix:::.memory.memory.used,sum(metrics.:::metric_prefix:::.memory.memory.*))
asPercent(metrics.:::metric_prefix:::.swap.swap.used,sum(metrics.:::metric_prefix:::.swap.swap.*))
```

... with the percentage returned being '100.0', despite this being very
*extremely* unlikely. Unfortunately, it's a very intermittent problem so
the exact cause of this is unknown.

Returning the median value should avoid this outlier.

This should also make this check more useful for rapidly changing
values, such as CPU checks.
Ensure we are dealing float datapoints

Convert strings to floats, but in a reliable manner.

Float() will only convert things that look like floats, whereas to_f is
a bit more leniant (eg nil.to_f == 0.0; Float(nil) throws an exception).
Add --method option, default to 'median'

Allow specification of a 'check method', so we can pick the right way
to discover the value to check against our thresholds. These vary
depending on the check needed.

* max
* min
* median (set as the default)
* mean
* last
* penultimate (throw away the last value, graphite sometimes corrupts
  it)
Handle the 'no roles defined' case.

This prevents a failure when a server has no defined roles grain.

Previously, failed with:

```
Comment: Unable to manage file: Jinja error: 'NoneType' object is not iterable
              Traceback (most recent call last):
                File "/usr/lib/pymodules/python2.7/salt/utils/templates.py", line 263, in render_jinja_tmpl
                  output = jinja_env.from_string(tmplstr).render(**unicode_context)
                File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 894, in render
                  return self.environment.handle_exception(exc_info, True)
                File "<template>", line 7, in top-level template code
                File "/usr/lib/python2.7/dist-packages/jinja2/filters.py", line 698, in do_list
                  return list(value)
              TypeError: 'NoneType' object is not iterable

              ; line 7

              ---
              [...]
              {
                "client": {
                  "name": "{{grains['fqdn']}}",
                  "address": "{{grains['fqdn_ip4']}}",
                  "metric_prefix": "{{ grains['fqdn'].split('.')|reverse| join('.') }}",
                  "subscriptions": {{(roles|list + ['all']|list) |json}}    <======================
                }
              }
```
Merge pull request #30 from ministryofjustice/missing_roles_ok

Handle the 'no roles defined' case.
Allow specification of Sensu Hipchat 'from' field

This defaults to 'Sensu' in the hipchat handler, which can be
misleading if you have staging and production logging to the same
room.

This enables the following pillar to override it sensibly.

```
sensu:
  notify:
    hipchat_from: 'Sensu Staging'
```
fix typo
Merge pull request #31 from ministryofjustice/hipchat_from

Allow specification of Sensu Hipchat 'from' field
Merge branch 'master' into median-not-last
Merge pull request #28 from ministryofjustice/median-not-last

--method option, to use median/mode/last/etc to calculate the value to check against thresholds.
Plugin update requires a client restart

At least when using EMBEDDED_RUBY=true, it seems that we need to
restart the client to pick up updates to the plugin/*.rb files.

Noticed this with the recent update to ruby-graphite.rb
sensu-server needs to be restarted if checks added

Sensu server needs to be made aware that there are new checks to
distribute.

Noticed this during addition of the swap-out graphite check.
Fix corner case where no roles are defined.
Bug with watching recursed directory?

Making this change as we got:

```
The following requisites were not found:
  watch:
    file:
      /etc/sensu/plugins/*
```

... probably because the resources are not named directly?
Simpler default fix using grain.get
Merge pull request #33 from ministryofjustice/fix_watchers

Fix watchers
Add a swap-out graphite-data check

Checking for actual paging is a better check than monitoring the
amount of swap used -- primarily in that it will alert when paging
occurs.

When the paging stops the alert will clear, so it's important to
check this over a reasonable period of time - in this instance the
`--from -30mins` should ensure that we are in an error state for at
least 30 mins.

I've set the defaults to be '> 0' for warning, '> 10' for critical,
mostly because we will want to be aware of any paging activity. We
may want to adjust this to be less sensitive later.
Adjust swap defaults

Now we have swap-out monitoring, we can ease off the swap-free thresholds
Update CHANGELOG
Add 'playbook' support to our checks.

A playbook is a link to a documentation source describing the check and
potential resolutions. It should be written with a view to an
inexperienced member of staff being able to understand the issue.