icinga-hubot-script
Version:
A hubot script that takes notification messages from Icinga and post them to any IRC channel
73 lines (54 loc) • 2.25 kB
text/coffeescript
icingaVariables =
ircChannel: 'ICINGA_CONTACTADDRESS0'
hostname: 'ICINGA_HOSTDISPLAYNAME'
hostOutput: 'ICINGA_HOSTOUTPUT'
hostStateId: 'ICINGA_HOSTSTATEID'
serviceOutput: 'ICINGA_SERVICEOUTPUT'
serviceDescription: 'ICINGA_SERVICEDESC'
serviceDescriptionLong: 'ICINGA__SERVICEDESCRIPTION'
serviceStateId: 'ICINGA_SERVICESTATEID'
serviceProblemId: 'ICINGA_SERVICEPROBLEMID'
lastServiceProblemId: 'ICINGA_LASTSERVICEPROBLEMID'
hostProblemId: 'ICINGA_HOSTPROBLEMID'
lastHostProblemId: 'ICINGA_LASTHOSTPROBLEMID'
notificationType: 'ICINGA_NOTIFICATIONTYPE'
hostActionUrl: 'ICINGA_HOSTACTIONURL'
serviceActionUrl: 'ICINGA_SERVICEACTIONURL'
notificationAuthor: 'ICINGA_NOTIFICATIONAUTHOR'
notificationComment: 'ICINGA_NOTIFICATIONCOMMENT'
class IcingaNotification
constructor: (icingaData) ->
= icingaData
ircChannel: ->
return [icingaVariables.ircChannel]
hostname: ->
return [icingaVariables.hostname]
serviceDescription: ->
return [icingaVariables.serviceDescription]
isProblem: ->
return [icingaVariables.notificationType] == 'PROBLEM'
isDowntimeStart: ->
return [icingaVariables.notificationType] == 'DOWNTIMESTART'
isDowntimeCancelled: ->
return [icingaVariables.notificationType] == 'DOWNTIMECANCELLED'
isRecovery: ->
return [icingaVariables.notificationType] == 'RECOVERY'
hostState: ->
return [icingaVariables.hostStateId]
isServiceNotification: ->
return !![icingaVariables.serviceProblemId] || !![icingaVariables.lastServiceProblemId]
isHostNotification: ->
return !
serviceState: ->
return [icingaVariables.serviceStateId]
hostActionUrl: ->
return [icingaVariables.hostActionUrl]
serviceActionUrl: ->
return [icingaVariables.serviceActionUrl]
isAcknowledgement: ->
return [icingaVariables.notificationType] == 'ACKNOWLEDGEMENT'
author: ->
return [icingaVariables.notificationAuthor]
comment: ->
return [icingaVariables.notificationComment]
module.exports = IcingaNotification