Increase control on data printed

maas has some particular requirements regarding the output. This
commit attempts to address the following:

- Report an error if the script attempts to return more than 30 metrics.
While the agent does log this and does stop sending metrics the status
of the check remains available. This could cause issues if the metrics
aren't used with alarms

- Uncaught exceptions generate a status message.
Exceptions don't generate a status message unless one is explicitly
set. Sometimes an exception may only occur if run by the agent. Status
messages have a limit of 256 characters so the text is taken from the
tail of the traceback.

- Strip newlines from output
The agent treats each line separately. Multi-line output such as
exceptions needs to have newlines escaped so that it can be used in the
status message.

- Use the last status message
The agent uses the first status message it receives and logs any that
follow as duplicates. If an error happens after an okay status message
the message needs to be updated.
29 is correct. The test happens prior to appending to METRICS. So if len(METRICS) == 29 and another METRIC needs appending to the list the if statement is skipped and the metric appended. That makes 30 and so if metric is called again the test will fail and the error is raised.