feat: integration with xo-server-transport-nagios (#17)

This commit is contained in:
badrAZ 2016-12-14 17:24:55 +01:00 committed by Julien Fontanet
parent d585b47360
commit c708fd65d7

View File

@ -63,6 +63,7 @@ class BackupReportsXoPlugin {
let reportWhen let reportWhen
const text = [] const text = []
const nagiosText = []
forEach(status.calls, call => { forEach(status.calls, call => {
// Ignore call if it's not a Backup a Snapshot or a Disaster Recovery. // Ignore call if it's not a Backup a Snapshot or a Disaster Recovery.
@ -105,6 +106,12 @@ class BackupReportsXoPlugin {
` - End time: ${String(end)}`, ` - End time: ${String(end)}`,
` - Duration: ${duration}` ` - Duration: ${duration}`
].join('\n')) ].join('\n'))
if (call.error) {
nagiosText.push(
`[ ${vm ? vm.name_label : 'undefined'} : ${call.error.message} ]`
)
}
}) })
// No backup calls. // No backup calls.
@ -140,6 +147,7 @@ class BackupReportsXoPlugin {
].join('\n')) ].join('\n'))
const markdown = text.join('\n') const markdown = text.join('\n')
const markdownNagios = nagiosText.join(' ')
// TODO : Handle errors when `sendEmail` isn't present. (Plugin dependencies) // TODO : Handle errors when `sendEmail` isn't present. (Plugin dependencies)
@ -156,6 +164,10 @@ class BackupReportsXoPlugin {
}), }),
xo.sendSlackMessage && xo.sendSlackMessage({ xo.sendSlackMessage && xo.sendSlackMessage({
message: markdown message: markdown
}),
xo.sendPassiveCheck && xo.sendPassiveCheck({
status: globalSuccess ? 0 : 2,
message: globalSuccess ? `[Xen Orchestra] [Success] Backup report for ${tag}` : `[Xen Orchestra] [Failure] Backup report for ${tag} - VMs : ${markdownNagios}`
}) })
]) ])
} }