diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index 2e9951a7b..65cc15b13 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -23,6 +23,7 @@ - Fix default filters not being set in all tables (PR [#4994](https://github.com/vatesfr/xen-orchestra/pull/4994)) - [SDN Controller] Broken encrypted tunnels after host reboot [#4996](https://github.com/vatesfr/xen-orchestra/pull/4996) - Don't log server's credentials in case of `SESSION_AUTHENTICATION_FAILED` error (PR [#4995](https://github.com/vatesfr/xen-orchestra/pull/4995)) +- [Plugin/perf-alert] Fix compatibility of the alert messages with XenCenter (PR [#5004](https://github.com/vatesfr/xen-orchestra/pull/5004)) ### Released packages @@ -41,6 +42,7 @@ > > In case of conflict, the highest (lowest in previous list) `$version` wins. +- xo-server-perf-alert patch - xen-api patch - xo-server-auth-ldap minor - xo-server-sdn-controller patch diff --git a/packages/xo-server-perf-alert/src/index.js b/packages/xo-server-perf-alert/src/index.js index 7c8a2d262..d315e44d3 100644 --- a/packages/xo-server-perf-alert/src/index.js +++ b/packages/xo-server-perf-alert/src/index.js @@ -3,6 +3,12 @@ import { createSchedule } from '@xen-orchestra/cron' import { forOwn, map, mean } from 'lodash' import { utcParse } from 'd3-time-format' +const XAPI_TO_XENCENTER = { + cpuUsage: 'cpu_usage', + memoryUsage: 'mem_usage', + storageUsage: 'physical_utilisation', +} + const COMPARATOR_FN = { '>': (a, b) => a > b, '<': (a, b) => a < b, @@ -33,6 +39,7 @@ const VM_FUNCTIONS = { getDisplayableValue, shouldAlarm: () => COMPARATOR_FN[comparator](getDisplayableValue(), threshold), + threshold, } }, }, @@ -58,6 +65,7 @@ const VM_FUNCTIONS = { getDisplayableValue, shouldAlarm: () => COMPARATOR_FN[comparator](getDisplayableValue(), threshold), + threshold, } }, }, @@ -88,6 +96,7 @@ const HOST_FUNCTIONS = { getDisplayableValue, shouldAlarm: () => COMPARATOR_FN[comparator](getDisplayableValue(), threshold), + threshold, } }, }, @@ -113,6 +122,7 @@ const HOST_FUNCTIONS = { getDisplayableValue, shouldAlarm: () => COMPARATOR_FN[comparator](getDisplayableValue(), threshold), + threshold, } }, }, @@ -131,6 +141,7 @@ const SR_FUNCTIONS = { getDisplayableValue, shouldAlarm: () => COMPARATOR_FN[comparator](getDisplayableValue(), threshold), + threshold, } }, }, @@ -487,6 +498,8 @@ ${monitorBodies.join('\n')}` data, value: data.getDisplayableValue(), shouldAlarm: data.shouldAlarm(), + threshold: data.threshold, + observationPeriod, }) } } else { @@ -499,6 +512,8 @@ ${monitorBodies.join('\n')}` Object.assign(result, { value: data.getDisplayableValue(), shouldAlarm: data.shouldAlarm(), + threshold: data.threshold, + observationPeriod, }) } @@ -596,23 +611,23 @@ ${entry.listItem}` continue } - const raiseAlarm = alarmId => { - // sample XenCenter message: - // value: 1.242087 config: - this._xo - .getXapi(entry.object.uuid) - .call( - 'message.create', - 'ALARM', - 3, - entry.object.$type, - entry.object.uuid, - `value: ${entry.value.toFixed( - 1 - )} config: ` - ) + const raiseAlarm = _alarmId => { + // sample XenCenter message (linebreaks are meaningful): + // value: 1.242087\n config: \n \n\n \n + this._xo.getXapi(entry.object.uuid).call( + 'message.create', + 'ALARM', + 3, + entry.object.$type, + entry.object.uuid, + `value: ${(entry.value / 100).toFixed(1)} +config: + + + + +` + ) this._sendAlertEmail( '', ` @@ -623,7 +638,7 @@ ${entry.listItem} ) } - const lowerAlarm = alarmId => { + const lowerAlarm = _alarmId => { this._sendAlertEmail( 'END OF ALERT', `