fix(xo-server-perf-alert): make message compatible with XenCenter (#5004)
This commit is contained in:
parent
3388e5e8a4
commit
6cf211a9ad
@ -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
|
||||
|
@ -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: <variable> <name value="mem_usage"/> </variable>
|
||||
this._xo
|
||||
.getXapi(entry.object.uuid)
|
||||
.call(
|
||||
'message.create',
|
||||
'ALARM',
|
||||
3,
|
||||
entry.object.$type,
|
||||
entry.object.uuid,
|
||||
`value: ${entry.value.toFixed(
|
||||
1
|
||||
)} config: <variable> <name value="${
|
||||
monitor.variableName
|
||||
}"/> </variable>`
|
||||
)
|
||||
const raiseAlarm = _alarmId => {
|
||||
// sample XenCenter message (linebreaks are meaningful):
|
||||
// value: 1.242087\n config: <variable>\n <name value="mem_usage"/>\n<alarm_trigger_level value="0.5"/>\n <alarm_trigger_period value ="60"/>\n</variable>
|
||||
this._xo.getXapi(entry.object.uuid).call(
|
||||
'message.create',
|
||||
'ALARM',
|
||||
3,
|
||||
entry.object.$type,
|
||||
entry.object.uuid,
|
||||
`value: ${(entry.value / 100).toFixed(1)}
|
||||
config:
|
||||
<variable>
|
||||
<name value="${XAPI_TO_XENCENTER[monitor.variableName]}"/>
|
||||
<alarm_trigger_level value="${entry.threshold / 100}"/>
|
||||
<alarm_trigger_period value ="${entry.observationPeriod}"/>
|
||||
</variable>`
|
||||
)
|
||||
this._sendAlertEmail(
|
||||
'',
|
||||
`
|
||||
@ -623,7 +638,7 @@ ${entry.listItem}
|
||||
)
|
||||
}
|
||||
|
||||
const lowerAlarm = alarmId => {
|
||||
const lowerAlarm = _alarmId => {
|
||||
this._sendAlertEmail(
|
||||
'END OF ALERT',
|
||||
`
|
||||
|
Loading…
Reference in New Issue
Block a user