CP-13494: perfmon: Monitor and alert for SR space
CP-13494: perfmon: Monitor and alert for SR space

This introduces a new class of Monitor in perfmon since now there is
a first-class SR RRD type.

There is currently just one variable that can be monitored, physical
utilisation. A special consolidation function has been specified to calculate
the percentage usage based on the absolute datasource values `size` and
`physical_utilisation`.

The SR can have alerts enabled for it in the usual way by setting the
other-config:perfmon key to an XML configuration for the object required. In
this case the `name` is `physical_utilisation`. The `alarm_trigger_level` can
be specified as a float between 0.0 and 1.0 which defaults to 0.8.

For example, to receive alerts when the physical utilisation of the SR goes
above 70%, set the SR config key as follows:

    $ CONFIG='<config><variable><name value="physical_utilisation"/><alarm_trigger_level value="0.7"/></variable></config>'
    $ xe sr-param-set uuid=0b4c2559-4e1e-4d83-1a35-746bfa94d76c \
        other-config:perfmon='$CONFIG'

This generates Xapi alerts of the following form:

    $ xe message-list class=SR
    uuid ( RO)         : 87f09079-7199-fcbb-7793-efe2174bbfe0
             name ( RO): ALARM
         priority ( RO): 3
            class ( RO): SR
         obj-uuid ( RO): 0b4c2559-4e1e-4d83-1a35-746bfa94d76c
        timestamp ( RO): 20150908T17:17:22Z
             body ( RO): value: 0.761889
    config:
    <variable>
            <name value="physical_utilisation"/>
            <alarm_trigger_level value="0.7"/>
    </variable>

Signed-off-by: Si Beaumont <a0992b7f1f450b4c7716d34b81a2d6f0877ae11a@citrix.com>

simonjbeaumont/xen-api,salvocambria/xen-api,vasilenkomike/xen-api,agimofcarmen/xen-api,guard163/xen-api,simonjbeaumont/xen-api,simonjbeaumont/xen-api,thomassa/xen-api,robertbreker/xen-api,rafalmiel/xen-api,Frezzle/xen-api,salvocambria/xen-api,euanh/xen-api,agimofcarmen/xen-api,salvocambria/xen-api,guard163/xen-api,vasilenkomike/xen-api,thomassa/xen-api,euanh/xen-api,srowe/xen-api,robertbreker/xen-api,rafalmiel/xen-api,agimofcarmen/xen-api,anoobs/xen-api,thomassa/xen-api,jjd27/xen-api,euanh/xen-api,robertbreker/xen-api,anoobs/xen-api,euanh/xen-api,srowe/xen-api,rafalmiel/xen-api,rafalmiel/xen-api,jjd27/xen-api,vasilenkomike/xen-api,srowe/xen-api,vasilenkomike/xen-api,guard163/xen-api,simonjbeaumont/xen-api,guard163/xen-api,agimofcarmen/xen-api,vasilenkomike/xen-api,simonjbeaumont/xen-api,anoobs/xen-api,anoobs/xen-api,jjd27/xen-api,euanh/xen-api,jjd27/xen-api,guard163/xen-api,robertbreker/xen-api,vasilenkomike/xen-api,srowe/xen-api,Frezzle/xen-api,Frezzle/xen-api,robertbreker/xen-api,agimofcarmen/xen-api,Frezzle/xen-api,euanh/xen-api,thomassa/xen-api,anoobs/xen-api,agimofcarmen/xen-api,rafalmiel/xen-api,anoobs/xen-api,salvocambria/xen-api,salvocambria/xen-api,Frezzle/xen-api,robertbreker/xen-api,rafalmiel/xen-api,simonjbeaumont/xen-api,jjd27/xen-api,guard163/xen-api,srowe/xen-api,thomassa/xen-api,thomassa/xen-api,salvocambria/xen-api,jjd27/xen-api